How to write production-ready go program

Jul 20 · 4 min read

Steps to follow

Formatting code with gofmt

# will only show the differences
gofmt -d filename.go
# will apply the changes
gofmt -w filename.go

Writing comment

// Package cook provides handy conversion methods for units typically used in recipes.
package cook
// TbsToMl converts tablespoons to milliliters.
func TbsToMl(tbs int) int {
// ...

Using golint

Running the tests

go test -v --bench . --benchmem

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade