gpt4 book ai didi

Go找不到本地包

转载 作者:数据小太阳 更新时间:2023-10-29 03:26:00 29 4
gpt4 key购买 nike

我有两个项目,一个是库,另一个是实用程序。我已经使用 go install 来构建库并将其放置在 pkg 区域中。这似乎按预期工作。

sbio $ pwd
/home/mjohn/workspaces/goprojects/src/crown/sbio
sbio $ CC=armv7l-timesys-linux-gnueabi-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 go install
sbio $ ls ../../../pkg/linux_arm/crown
sbio.a

我的问题是当我试图让我的实用程序使用这个库时。它提示 no buildable Go source files 但它在 src 目录下查找,这让我认为它在 pkg 区域中看不到它。我在实用程序中的导入路径是 crown/sbio。任何想法都会有所帮助。

utility $ GOOS=linux GOARCH=arm GOARM=7 go build
go build crown/sbio: no buildable Go source files in /home/mjohn/workspaces/goprojects/src/crown/sbio

utility $ GOOS=linux GOARCH=arm GOARM=7 go build -v -x -work
WORK=/tmp/go-build709862068
crown/sbio
github.com/jessevdk/go-flags
mkdir -p $WORK/github.com/jessevdk/go-flags/_obj/
os/signal
mkdir -p $WORK/github.com/jessevdk/
cd /home/mjohn/workspaces/goprojects/src/github.com/jessevdk/go-flags
/home/mjohn/software/go/pkg/tool/linux_386/compile -o $WORK/github.com/jessevdk/go-flags.a -trimpath $WORK -p github.com/jessevdk/go-flags -complete -buildid 2e7b82d3996437f712d51c2be269e6cd3eb809d6 -D _/home/mjohn/workspaces/goprojects/src/github.com/jessevdk/go-flags -I $WORK -pack ./arg.go ./closest.go ./command.go ./command_private.go ./completion.go ./convert.go ./error.go ./flags.go ./group.go ./group_private.go ./help.go ./ini.go ./ini_private.go ./man.go ./multitag.go ./option.go ./option_private.go ./optstyle_other.go ./parser.go ./parser_private.go ./termsize.go ./termsize_linux.go
mkdir -p $WORK/os/signal/_obj/
mkdir -p $WORK/os/
cd /home/mjohn/software/go/src/os/signal
/home/mjohn/software/go/pkg/tool/linux_386/compile -o $WORK/os/signal.a -trimpath $WORK -p os/signal -buildid 36d5db084a1ab49c3fbb474d340be7996d6606d8 -D _/home/mjohn/software/go/src/os/signal -I $WORK -pack -asmhdr $WORK/os/signal/_obj/go_asm.h ./doc.go ./signal.go ./signal_unix.go
mkdir -p $WORK/crown/sbio/_obj/
mkdir -p $WORK/crown/
go build crown/sbio: no buildable Go source files in /home/mjohn/workspaces/goprojects/src/crown/sbio
/home/mjohn/software/go/pkg/tool/linux_386/asm -o $WORK/os/signal/_obj/sig.o -trimpath $WORK -I $WORK/os/signal/_obj/ -I /home/mjohn/software/go/pkg/include -D GOOS_linux -D GOARCH_arm ./sig.s
pack r $WORK/os/signal.a $WORK/os/signal/_obj/sig.o # internal

utility $ go env
GOARCH="386"
GOBIN=""
GOEXE=""
GOHOSTARCH="386"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/mjohn/workspaces/goprojects"
GORACE=""
GOROOT="/home/mjohn/software/go"
GOTOOLDIR="/home/mjohn/software/go/pkg/tool/linux_386"
CC="gcc"
GOGCCFLAGS="-fPIC -m32 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build583017880=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"

utility $ go version
go version go1.7.4 linux/386

感谢您的帮助。

最佳答案

我能够通过使用定义的 CCCGO_ENABLED 变量构建实用程序来解决我的问题。我需要为构建实用程序定义它们,即使它不包含任何 cgo 代码,但由于库的原因,它仍然需要。

如果可以在不需要这样做的情况下构建实用程序,我仍然会感兴趣,因为让库的每个用户都需要定义这些是很痛苦的。

关于Go找不到本地包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41682683/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com