I have two go files with different build constraints in the header.
constants_production.go:
// +build production,!staging
package main
const (
URL = "production"
)
constants_staging.go:
// +build staging,!production
package main
const (
URL = "staging"
)
main.go:
package main
func main() {
fmt.Println(URL)
}
When I do a go install -tags "staging"
, sometimes, it prints production
; Sometimes, it prints staging
. Similarly, when I do go install -tags "production"
,...
How do I get a consistent output on every build? How do I make it print staging when I specify staging as a build flag? How do I make it print production when I specify production as a build flag? Am I doing something wrong here?