logoalt Hacker News

Groxxyesterday at 4:57 PM2 repliesview on HN

I suspect that using a build tag (say `test`) and two function definitions (one that directly calls `time.Now()` and one test-only one that uses a mutable var) will optimize out to zero cost in the non-test case - last I fiddled with that, it was pretty good at consistently inlining trivial wrapper funcs like that.


Replies

awesome_dudeyesterday at 9:35 PM

The compiler will only use _test.go files in the test build - so not an explicit build tag, but a built in one.

show 1 reply