Is there any documentation/rules for designing a go pacakge

I would like to learn how effectively we can design a go package. it would be great help if you provide me some documentation or design Techniques

1 Like

Will effective go helps? It has all the rules, structure, practices, etc. in it.

Something important is to use go module over the classical distribution methods like GOPATH and vendor. Documentations are available at:

  1. https://github.com/golang/go/wiki/Modules
  2. https://blog.golang.org/using-go-modules
  3. https://blog.golang.org/migrating-to-go-modules

We normally have tools that handle all the systematic practices on-the-job like:

  1. go fmt that handles source codes formatting.
  2. golangci-lint that handles all sort of static analysis.
  3. advanced go test (with coverage, etc.)

If you need to model some references:

  1. https://github.com/kubernetes/kubernetes
  2. https://github.com/golang/go/tree/master/src (make sure it is inside src, since go package discourage the use of src)

If you want, you can read up some additional materials:

  1. https://dave.cheney.net/practical-go/presentations/qcon-china.html - some good practices
  2. https://sites.google.com/view/chewkeanho/guides/go/testing - setting up test tools
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.