Automated build

Hi,

I’ve got a project with a fair share of third party dependencies. I’m trying to automate the build of this project so that our sysadmins can install it on servers without needing to know all about the dependencies. I thought I had it nailed with a simple bashscript basically doing

go get ./...
go install myapp

It worked fine on my development machine but not so much anywhere else. There it breaks with:

src/github.com/onsi/gomega/ghttp/handlers.go:12:2: cannot find package "github.com/golang/protobuf/proto" in any of:
    /home/me/tech-64/src/vendor/github.com/golang/protobuf/proto (vendor tree)
    /opt/go/src/github.com/golang/protobuf/proto (from $GOROOT)
    /home/me/tech-64/src/github.com/golang/protobuf/proto (from $GOPATH)
src/golang.org/x/text/cmd/gotext/main.go:29:2: cannot find package "golang.org/x/tools/go/buildutil" in any of:
    /home/me/tech-64/src/vendor/golang.org/x/tools/go/buildutil (vendor tree)
    /opt/go/src/golang.org/x/tools/go/buildutil (from $GOROOT)
    /home/me/tech-64/src/golang.org/x/tools/go/buildutil (from $GOPATH)
src/golang.org/x/text/cmd/gotext/extract.go:23:2: cannot find package "golang.org/x/tools/go/loader" in any of:
    /home/me/tech-64/src/vendor/golang.org/x/tools/go/loader (vendor tree)
    /opt/go/src/golang.org/x/tools/go/loader (from $GOROOT)
    /home/me/tech-64/src/golang.org/x/tools/go/loader (from $GOPATH)

Does anyone know of a way to get this to work? That is being able to fetch all dependencies and compile my project on a server with as little as possible on it? Currently vanilla Go 1.6 or 1.7

Thanks

What happens if you run ?

go get github.com/you/yourapp

It’s sadly in a private non-github repo, which I need to checkout and then in there I run go get so I can’t do the above

Make super duper sure you’re checking your code out into the correct location. This error looks like code in your GOPATH is not laid out correctly…

Trying to make it as small as possible I tried this. I created a file src/foo/foo.go:

package main

import (
    log "github.com/Sirupsen/logrus"
)

func main() {
    log.Error("Foo")
}

Then in the shell:

$ export GOPATH=`pwd`
$ go install foo
src/foo/foo.go:4:2: cannot find package "github.com/Sirupsen/logrus" in any of:
    /opt/go/src/github.com/Sirupsen/logrus (from $GOROOT)
    /home/me/test/src/github.com/Sirupsen/logrus (from $GOPATH)
jmo@tm-x33m0n-01:~/test$ go get ./...
src/github.com/Sirupsen/logrus/examples/hook/hook.go:5:2: cannot find package "gopkg.in/gemnasium/logrus-airbrake-hook.v2" in any of:
    /opt/go/src/gopkg.in/gemnasium/logrus-airbrake-hook.v2 (from $GOROOT)
    /home/me/test/src/gopkg.in/gemnasium/logrus-airbrake-hook.v2 (from $GOPATH)
$ go get ./...
$ go install foo
$

So it seems go get fails to recursively fetch all dependencies the first time, but the second time it works. In my larger project I need to do it three times for it to work, and the third time it complains about not being allowed to install godoc to $GOROOT/bin even though godoc is already installed there and in my path. But after the third time I can do “go install myapp”.

So I guess in a sense it’s solved, I do go get ./... &>/dev/null four times (for good measure) before doing go install. It would be nice to know why this happens thought.

go get -v foo should be all that is required assuming that the source to foo is at $GOPATH/src/foo

That did it, thanks a bunch!

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