Dev vs. production builds
suggest changeFor 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.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents