[go-nuts] time.Now takes ~3758 ns/op, is that normal?

2018-05-25 Thread mfriedenhagen
Hello, I downloaded your gist and these are my results: ~/.Trash$ $ curl -s -O https://gist.githubusercontent.com/reinit/82608ab20e5aac3bd3c1eb5a8f78d23c/raw/bbc6fdb1ad0f137a66a986fe2af931ea477b5625/time_now_test.go ; go version ; go test -bench . go version go1.10.2 darwin/amd64 goos: darwin g

Re: [go-nuts] How to fake os.Stdout in golang for testing?

2018-05-06 Thread mfriedenhagen
ew(buf, "", 0) > Hello Alex, good point, however firstly I do not want to modify the original code. My first goal is to cover it completely with tests. This being a test project for legacy code refactoring, the program *must* always produce the output given here: https://github.com

Re: [go-nuts] How to fake os.Stdout in golang for testing?

2018-05-06 Thread mfriedenhagen
On Sunday, May 6, 2018 at 7:32:47 AM UTC+2, Lars Seipel wrote: > > On Sat, May 05, 2018 at 08:55:17AM -0700, mfried...@gmail.com > wrote: > > * Now in golang `os.Stdout` is an `*os.File` which is mostly a wrapper > for > > an OS specific file. > > You can always use os.Pipe to get an actual f

[go-nuts] How to fake os.Stdout in golang for testing?

2018-05-05 Thread mfriedenhagen
question whether I miss something or is faking os.Stdout really hard? Any hints appreciated :-) Regards Mirko [1] https://martinfowler.com/articles/mocksArentStubs.html#TheDifferenceBetweenMocksAndStubs [2] https://github.com/mfriedenhagen/trivia/commit/b8ecec0097bfb4a6e7e2992e1401274cff06c03b#di