Cache or tmp file used by golang compiler?

4,539 views
Skip to first unread message

Uriel Fanelli

unread,
Aug 12, 2015, 4:29:39 AM8/12/15
to golang-nuts

Hi all

I am facing a strange behavior in "go build"  process.

What I am doing is , from time to time, to do a git pull from a github repository and recompile the source
of a program. (the program is "gogs", https://github.com/gogits/gogs , just for mention).

What happens to me is that I compile an executable , and the binary is always the same, regardless the source
code has changed.

At the beginning I tried with all favours of "go clean", like "go clean -r" , but the result is the same: after a certain moment,
dunno why, one machine has continued to produce  an "old" binary, and it was the machine I used to compile the same program in the past.

Now, my question is: is there any kind of cache, tmp file, whatever the compiler uses, which I could try to clean
in order to have a very new executable? This issue is making me crazy, seems this machine is producing always the same
executable.

The version of golang I'm using is 1.4.2  64 bit, CC=gcc48

Uriel



Fredrik Ehnbom

unread,
Aug 12, 2015, 6:24:33 AM8/12/15
to golang-nuts
Does "which <programname>" output what you expect?

Try "go build -a" and if that doesn't work try "rm -rf  `go env GOPATH`/pkg/`go env GOOS`_`go env GOARCH`".

/f

Uriel Fanelli

unread,
Aug 12, 2015, 8:13:42 AM8/12/15
to golang-nuts
Yes, I tried to search for other programs with the same name.
There was the only program existing with wuch a name.
And I also check the md5 , the binary is being produced the same.

Anyhow, this suggestion did't worked.

Basically the problem is very weird:

This source says the "Safe" function exists:

 https://github.com/gogits/gogs/blob/develop/modules/base/template.go#L135

And the template lists the function:

https://github.com/gogits/gogs/blob/develop/templates/repo/pulls/fork.tmpl

When I compile this on a "vanilla"  linux machine, it works properly.
Then I compile the same on another machine, 64 bit with gcc48 , and:

panic: template: repo/pulls/fork:50: function "Safe" not defined



goroutine
1 [running]:
html
/template.Must(0x0, 0x8010ed440, 0xc20844d130, 0x0)
/home/loweel/go/src/html/template/template.go:304 +0x50
github
.com/Unknwon/macaron.compile(0xc2082312c0, 0x18, 0x0, 0x0, 0xc2082312e0, 0x2, 0x2, 0xc20802d558, 0x1, 0x1, ...)
 



the compiler is compiling a working binary of "something", which works perfectly with the templates of the old version,
but is not containing the function specified.

So it seems some "cached" version of the binary is generated. But I am gettig crazy on that....

Roberto Zanotto

unread,
Aug 12, 2015, 8:58:05 AM8/12/15
to golang-nuts
I'm sorry to tell you, but the simplest explanation is that on one machine you are recompiling an old version of your program source. Are you 100% sure that the "Safe" function exists in the source file that you are actually compiling?

jo...@claireit.nl

unread,
Aug 12, 2015, 9:59:45 AM8/12/15
to golang-nuts
Try go install instead of go build: I suspect you compile one but run another one...

Op woensdag 12 augustus 2015 10:29:39 UTC+2 schreef Uriel Fanelli:

ddxgz1...@gmail.com

unread,
Dec 13, 2016, 7:14:06 PM12/13/16
to golang-nuts, uriel....@gmail.com
Hi Uriel,

How did you solve this problem? Because I'm facing the same.

在 2015年8月12日星期三 UTC+2上午10:29:39,Uriel Fanelli写道:

Dave Cheney

unread,
Dec 13, 2016, 7:25:48 PM12/13/16
to golang-nuts, uriel....@gmail.com, ddxgz1...@gmail.com
Try go install -v, you'll find the program in $GOPATH/bin. If you get no lines of output, then the program is up to date.

ddxgz1...@gmail.com

unread,
Dec 14, 2016, 7:35:54 AM12/14/16
to golang-nuts, uriel....@gmail.com, ddxgz1...@gmail.com
I found my problem was caused by an unsuccessfully exited process. Thanks for your help anyway.

在 2016年12月14日星期三 UTC+1上午1:25:48,Dave Cheney写道:

timothy....@gmail.com

unread,
Apr 11, 2017, 1:11:16 PM4/11/17
to golang-nuts, uriel....@gmail.com, ddxgz1...@gmail.com
I've run into a similar problem a few times.  Each time I ran across this article, but each time it was something like the following:

* Compiler says something like: `reindex/reindex.go:367: undefined: utils.EsDataTypeMap`
* I check the line, `utils.EsDataTypeMap` is not there.  The line is `dataType := converterUtils.EsDataTypeMap[msg.Type]`.
* I try moving the file `reindex/reindex.go ` around, doing all sorts of other weird activities to make sure I'm looking at the same file as the compiler.
* It turns out I have a line like this in my imports: `converterUtils "github.com/rand/thing/utils"`

So the compiler warning *looks* like it's wrong, but it really just ignores the import aliasing.
Reply all
Reply to author
Forward
0 new messages