#Go
In need to read for how long your Go program is running?
Instead of doing calculations use monotonic clock reading, available at any time during execution
https://t.co/FlevuhvzPi function reads 2 things: wall clock and monotonic clock
Latter one is a measure of how long current process is running in a sub-second precision
Cool thing to include in log sometimes
#golang #GoTip #GoTips
I can't stop using site: web search feature
Provided that website pages are indexed by search engines, there is no need for search functionality within a page. Simply looking for contents using site:<URL> suffice.
It's path aware, so search can be targetted to part of website.
Very useful if there are multiple versions of a publications, such as searching in most recent POSIX specification
#google #googlesearch #posix
#Go
Common misconception is that unix time in programming languages can't represent point in time before Epoch January 1, 1970 UTC
Simply subtract from starting point to get an instant representing point in the past
It's a great way to encode absolute time value
Note: in POSIX negative values are undefined, doesn't limit its utility though
refs:
https://t.co/4aovcMqzjk
https://t.co/H28HnC41cq
#golang #gotip #gotips #posix
#Go
It's such a different experience reading doc of a package that quotes RFCs or other standards as basis of it's implementation
It's like promise time spent reading the doc is worth the effort
✨ https://t.co/MIHx8VfaCI ✨ great example
#Go
Keeping documentation up to date with code is challenging
Runnable example as a test paradigm found in Go tackles this issue in a creative way
When we treat examples as a documentation its barely possible it gets out of date, additionally it promotes high-quality tests as it's included in public facing docs
Adopting this pattern is a piece of cake
1. add example_..._test.go with a test func
2. write test func printing expected results to stdout
3. validate results with //Output: comment
4. observe it being tested by testing suite automatically
5. observe it being included in go docs automatically
Immediate value in reducing both: outdated docs and low quality tests