KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I need to be able to build different versions of a go application; a 'debug' version and a normal version. This is easy to do; I simply have a const DEBUG, that controls the behaviour of the application, but it's annoying to have to edit the config file every time I need to swap between build types. I was reading about go build ( http://golang.org/pkg/go/build/ ) and tags, I thought perhaps I could do this: config.go: // +build !debug package build const DEBUG = false config.debug.go: // +build debug package build const DEBUG = true Then I should be able to build using go build or go build -tags debug , and the tags should exclude config.go and include config.debug.go . ...but this doesn't work. I get: src/build/config.go:3: DEBUG redeclared in this block (<0>) previous declaration at src/build/config.debug.go:3 What am I doing wrong? Is there another and more appropriate #ifdef style way of doing this I should be using?
Tags (comma-separated)
Save Edits
Cancel