Switching from gb to plain go - how?

I have a project (not mine!) written in Go, which uses gb to build it. It uses a fair amount of dependencies (“vendor” stuff).

Once go moved from 1.11 to 1.12, gb stopped working - it fails to link with the following errors:

golang.org/x/sys/unix.libc_close_trampoline·f: relocation target golang.org/x/sys/unix.libc_close_trampoline not defined for ABIInternal (but is defined for ABI0)
. . . . .
# yubihsm-connector
FATAL: command "build" failed: exit status 2

I would like to build this project manually, replicating what gb build would have done if it worked correctly. Unfortunately, as a complete beginner, I have no clue how Go build system works. Could you advise me on how to build this project manually? Just running go build caused some errors:

    $ go build
    main.go:30:2: cannot find package "github.com/kardianos/service" in any of:
        /usr/local/go/src/github.com/kardianos/service (from $GOROOT)
        . . . . . (from $GOPATH)
    . . . . .

so something must be missing - could you point me at what it is, and how to recreate it?


1 Like

Have you checked where the package is actually located ? Did you get it before building ?
What are the values of your GOPATH and GOROOT environment variables ? Did you check if the package is lying there ?

Yes, all the packages seem to be downloaded and located in vendor/src subdirectory of the project, which is $HOME/src/yubihsm-connector.

$ env | grep GO

It’s a gb project, so the directory structure is:

       --src/yubihsm-connector  (*.go files for the project itself)
                 --src   (all the dependencies/packages)

You should have your project src directory under your GOPATH directory.

1 Like

Is there any way around that? Maybe adding to GOPATH some path for the duration of go build?

Based on the above guidance, answering my own question: the following build command worked:

$ cd src/yubihsm-connector && GOPATH="${GOPATH}:${PWD}/vendor" go build

I haven’t experimented with

$ GOPATH="${GOPATH}:${PWD}/src:${PWD}/vendor" go build

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.