I have a program in Go that I want to compile in a bunch of binaries, each having a const
value defined differently. More clearly, I have something like that:
const wordLen = 6
type knowledge [wordLen]byte
Here, wordLen
is associated with the value 6, but I want to have different binaries, with values ranging from 5 to 10. I could make it a variable, and then use a slice rather than an array, but that would have a huge performance impact on my soft (yes, I tried).
I would love to have some build tag on go build
argument to indicate what the value of wordLen
is for a given binary. So, what is the (as idiomatic as possible) way to do this ?
go build
? Will the build end with an error complaining about undefined symbolf
? How can I provide a kind of defaults to use when neither-tags bar
, nor-tags foo
is specified? – Mesa