关于Go你不得不知道的小技巧


目录
  • atomic.Value

https://twitter.com/bbrodriges/status/873414658178396160
  • CGO_ENABLED=0 go build -ldflags="-s -w" app.go && tar C app | docker import - myimage:latest
  • ** run go format on CI and compare diff

    • 这将确保一切都是生成的和承诺的
  • ** 用最新的 Go 运行 Travis-CI,用 travis 1

  • ** 检查代码格式是否有错误 diff -u <(echo -n) <(gofmt -d .)

  • go-critic linter 从这个文件中强制执行几条建议

  • **

    go mod why -m  告诉我们为什么特定的模块在 go.mod 文件中。

  • **

    GOGC=off go build ... 应该会加快构建速度 source

  • **

    内存分析器每 512KB 记录一次分配。你能通过 GODEBUG 环境变量增加比例,来查看你的文件的更多详细信息。

  • **

    go mod why -m  告诉我们为什么特定的模块是在 go.mod 文件中。

  • https://github.com/cristaloleg/go-advice/blob/master/README_ZH.md

    Go