go install and build tags

1,145 views
Skip to first unread message

Johann Höchtl

unread,
Mar 1, 2012, 6:26:28 AM3/1/12
to golan...@googlegroups.com
Hello,

are go install build tags already supposed to work? As I understand, any unsatisfied tag causes the file not to build.

I use a single // +build ignore

but the file builds just fine (as part of a command). If it's important, this file also contains an init-function.

- Johann

Archos

unread,
Mar 1, 2012, 7:28:20 AM3/1/12
to golang-nuts
What release are you using? go version

There is documentation about the build constraints in the weekly
release:
http://weekly.golang.org/pkg/go/build/#Context.ScanDir

so it should works in the last weekly release

Johann Höchtl

unread,
Mar 1, 2012, 7:43:28 AM3/1/12
to golan...@googlegroups.com
Yes, that was my understanding of how build tags should work. I have put a single panic into the int function of the package, // +build ignore at the top of the file but the panic gets triggered.

Johann Höchtl

unread,
Mar 1, 2012, 7:49:28 AM3/1/12
to golan...@googlegroups.com


Am Donnerstag, 1. März 2012 13:28:20 UTC+1 schrieb Archos:
What release are you using? go version

Forgot to mention:

go version weekly.2012-02-22 +96bd78e7d35e
 

David Symonds

unread,
Mar 1, 2012, 7:54:19 AM3/1/12
to Johann Höchtl, golan...@googlegroups.com

Can you show the whole file, or at least the part up until the build directive?

Johann Höchtl

unread,
Mar 1, 2012, 8:27:45 AM3/1/12
to David Symonds, golan...@googlegroups.com
On 03/01/2012 01:54 PM, David Symonds wrote:
> Can you show the whole file, or at least the part up until the build
> directive?
>

I certainly could (and will) but I have narrowed down the "problem":

First I create a file a.go which is part of a package main and
deliberately panics
go install <packagespec>

Then I add // + build ignore and perform to this file and perform another

go install <packagespec>

What happens is, that the file IS ignored, but go install doesn't
recognize, that not visiting this file will change program semantics. go
install overoptimizes now and doesn't build the command again.

By ignoring this file go install and go build assumes that there is no
need to compile and link everything together again.

Manually go clean -i <packagespec> OR go install -a <packagespec> works
of course.

Seems like a bug in the dependency walker and hardly a feature as the
file _changes_ by adding +build ignore which should cause a recompile /
reinstall of dependent objects.

Johann

Andrew Gerrand

unread,
Mar 1, 2012, 6:07:33 PM3/1/12
to Johann Höchtl, David Symonds, golan...@googlegroups.com

Please file an issue:

http://code.google.com/p/go/issues/entry

Andrew

Johann Höchtl

unread,
Mar 2, 2012, 5:11:40 AM3/2/12
to golan...@googlegroups.com, Johann Höchtl, David Symonds
Reply all
Reply to author
Forward
0 new messages