Reputation: 84650
I'm running into a bizarre problem at work.
I have a project. In this project are two packages, each in its own folder. Each folder contains various .go
files that are part of that package.
In folder A, if I say go build -v
, I get a list of the stuff it's building.
In folder B, if I say go build -v
, I get an immediate return with no output.
Both folders contain nothing but .go
files, and there is no easily-identifiable reason why it is building the code in the one and building nothing in the other.
go version
returns go version go1.7.5 linux/amd64
How in the world do I figure out what's going on here?
EDIT: To clarify issues brought up in comments:
There is no package main
in either folder. In the folder A, go install
produces a .a
file in the appropriate place under $GOPATH/pkg
. In folder B, go install
does not. It is doing nothing, and failing silently. Something is legitimately going wrong here.
Suggested remedies from comments include using the -a
flag (errors out on something that appears to be completely unrelated) and using the -x
flag. The -x
flag, which supposedly should give extremely verbose output, instead is useless, outputting single lines referring to temp files that do not exist once the build terminates, such as WORK=/tmp/go-build026498757
.
Upvotes: 17
Views: 41769
Reputation: 21
I also faced a similar issue, don't know the root cause but run
go build main.go
Basically, add the filename and try.
Upvotes: 2
Reputation: 432
You mention that the temporary directories are gone after the build terminates.
You can retain these directories with the -work
flag.
From go help build
:
The build flags are shared by the build, clean, get, install, list, run, and test commands:
...
-work
print the name of the temporary work directory and
do not delete it when exiting.
This should help provide some more information and context around what is and is not happening.
Upvotes: 2
Reputation: 500
I think go build's result is hiding by your editor.(file tree)
In my case, I am using vscode.
vscode hides files that first char is '.'
if you move to src directory and type ls -al
in terminal
Upvotes: 0
Reputation: 5232
It's likely that you already have an up-to-date build installed in your gopath. This might mean that you did something like ran go install
on that particular package previously and have yet to modify any of the files in the directory.
Check Go's pkg
directory for the corresponding *.a
library and see if the modification timestamp on it is later than the timestamps on your source files.
Upvotes: 0