1. 单元测试


go test -v -cover go get -u github.com/stretchr/testify
2. Benchmark
go test -bench=.
ok go-learning/src/ch29/benchmark 0.334s
go test -bench=”.”
goos: windowsgoarch: amd64pkg: go-learning/src/ch29/benchmarkcpu: Intel(R) Core(TM) i5-8265U CPU @ 1.60GHzBenchmarkConcatStringByAdd-8 9803656 120.7 ns/opBenchmarkConcatStringByBytesBuffer-8 18998974 59.38 ns/opPASSok go-learning/src/ch29/benchmark 2.548s
go test -bench=”.” -benchmem
goos: windowsgoarch: amd64pkg: go-learning/src/ch29/benchmarkcpu: Intel(R) Core(TM) i5-8265U CPU @ 1.60GHzBenchmarkConcatStringByAdd-8 10114231 120.5 ns/op 16 B/op 4 allocs/opBenchmarkConcatStringByBytesBuffer-8 20040949 59.59 ns/op 64 B/op 1 allocs/opPASSok go-learning/src/ch29/benchmark 2.642s
3. Behavior Driven Development






