Configuration

  • flags inside main
func main() {
    var (
        payload = flag.String("payload", "abc", "payload data")
        delay   = flag.Duration("delay", 1*time.Second, "write delay")
    )
    flag.Parse()
    // ...
}

Logging and telemetry

  • push based telemetry is straightforward, but does not scale
  • expvar with pull based telemetry scales

Testing and validation

// +build integration
 
var fooAddr = flag.String(...)
 
func TestToo(t *testing.T) {
    f, err := foo.Connect(*fooAddr)
    // ...
}
  • go test -tags=integration

Interlude

  • std lib based conventions scale to large group of developers

Dependency Management

  • use vendor for executables
  • don’t use vendor for package

Conclusion

  • The ultimate best practice is to embrace simplicity

Reference