Dev vs. production builds

suggest change

For backend servers it's common to need dev vs. production configurations where you e.g. point to a different database server etc.

//go:build dev

package config

const (
	MONGODB_HOST = "mongodb://127.0.0.1:27017"
)
//go:build prod

package config

const (
	MONGODB_HOST = "mongodb://mongo.myserver.com:27017"
)

Build with go build -tags dev for the development file and go build -tags prod for the production file. The constraints are mutually exclusive, and a blank line after //go:build is required. Pass one of those tags; with neither tag, MONGODB_HOST is not defined.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents