I recently come across a spooky go build
problem as I add in some functions in the new version and renamed the old folder.
go version is 1.10.4, too old to have module management
I put all source code folders under /home/zxun/src/
And the new code folder is now "quotelive" in it, with the older version "quotelive_0831".
Now in the path /home/zxun/src/quotelive
go clean -cache -r
go build
And here is the output
# quotelive_0831
./signclient.go:231:6: undefined: "quotelive/util".Count
./testmod.go:95:5: undefined: "quotelive/util".Count
./timetask.go:32:2: undefined: "quotelive/util".Count
./ctp.go:412: undefined: "quotelive/util".Count
the Count function in util subfolder is of course absent in the old version 0831
But why does it come up # quotelive_0831
and encounter this dependency problem?
As I want to get around this problem by moving /home/zxun/src/quotelive_0831
to a new place /home/zxun/src_old/quotelive_0831
, it keeps haunting me!
# _/home/zxun/src_bkp/quotelive_0831
./signclient.go:231:6: undefined: "quotelive/util".Count
./testmod.go:95:5: undefined: "quotelive/util".Count
./timetask.go:32:2: undefined: "quotelive/util".Count
./ctp.go:412: undefined: "quotelive/util".Count
Using go build -v
in the former case it referenced quotelive_0831
, and in the latter it referenced _/home/zxun/src_bkp/quotelive_0831
, before flashing out those errors.
I tried go build -x
and find out it DID remember quotelive_0831
as the default building folder. The question is how to get rid of this memory?
~/src/quotelive$ go build -x
WORK=/tmp/go-build560195042
mkdir -p $WORK/b001/
cd /home/zxun/src_bkp/quotelive_0831
CGO_LDFLAGS='"-g" "-O2"' /usr/go10/pkg/tool/linux_amd64/cgo -objdir $WORK/b001/ -importpath _/home/zxun/src_bkp/quotelive_0831 -- -I $WORK/b001/ -g -O2 ./ctp.go
cd $WORK
gcc -fno-caret-diagnostics -c -x c - || true
gcc -Qunused-arguments -c -x c - || true
gcc -fdebug-prefix-map=a=b -c -x c - || true
gcc -gno-record-gcc-switches -c -x c - || true
cd $WORK/b001
In terms of "repeatable smallest case", try to copy your work folder and rename it by another name, as I did to quotelive
. And then try the build in your original one.
Recent update: I did work around it by using LiteIDE - Build - Force Build and it turned out no error. Force build applied the command:
/usr/go10/bin/go build -a -v [/home/zxun/src/quotelive]
CodePudding user response:
I did work around it by using LiteIDE - Build - Force Build and it turned out no error. LiteIDE showed what command it applied:
/usr/go10/bin/go build -a -v [/home/zxun/src/quotelive]
I tried to use go build -a -v
alone and it did work properly.
-a
is a Must.