On Mon, Oct 3, 2016 at 4:08 PM, <
singh....@gmail.com> wrote:
>
> Please see the code of main.go and main_test.go pasted at the end. Then
> consider the output of these commands. I would have expected the `go test`
> command's output to contain the value 'hello'. From `go help test` output,
> the `go test` command is supposed to honor all build flags, but clearly it
> isn't.
I don't think that's the problem. If you use the -x option with `go
test`, you should see that the -ldflags option is indeed being passed
to `go tool link`. I think the problem is that `go test` renames the
package being tested, so it no longer has the name `main`. That means
that your `-X` option is not using the right variable name.
I'm not sure whether this should be considered a bug or not.
Ian