简体   繁体   中英

Go can't find local package

I have two projects, one is a library and the other is a utility. I've used go install to build the library and place it in the pkg area. This seems to have worked as expected.

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

My issue is when I try to have my utility use this library. It complains about no buildable Go source files but its looking under the src directory, which makes me think its not seeing it in the pkg area. My import path in the utility is crown/sbio . Any ideas would be helpful.

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

Thanks for any help.

I was able to solve my issue by building the utility with the CC and CGO_ENABLED variables defined. I needed them defined for building the utility even though it didn't include any cgo code it was still needed because of the library.

If it's possible to build the utility without needing to do this I would still be interested as it's a pain to have every user of the library be required to define these.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM