0

I inherited a build script that builds a docker image and uses hashicorp/levant library to deploy. For a year or so we have been running go get github.com/jrasell/levant to grab the levant library. In past few days, the repo URL was merged under Hashicorp's organization and we've changed our script to pull with go get github.com/hashicorp/levant. But either way, we get this multi assign error. What does this mean, doesn't 'go' just basically pull the git repo?

../go/src/github.com/hashicorp/levant/template/render.go:28:11: cannot assign 
*"github.com/hashicorp/nomad/vendor/github.com/hashicorp/nomad/api".Job to job 
(type *"github.com/hashicorp/nomad/api".Job) in multiple assignment
shmsr
  • 3,802
  • 2
  • 18
  • 29
personalt
  • 810
  • 3
  • 13
  • 26

2 Answers2

0

Firstly, go get works with packages, not repositories.

In addition to pulling them go get also compiles and installs them, and here's when your error pops up.

More info here:

https://nanxiao.gitbooks.io/golang-101-hacks/content/posts/go-get-command.html

0

I recommend you to use Go modules.

hashicorp/levant does have go.{mod,sum} files and hence you should forget using the go get way.

It's better to do a clone and follow the go module way i.e.,

git clone git@github.com:hashicorp/levant.git
go test ./...
go build ./...

The steps with not only just clone your repo but would also bring your dependent packages required for building/ testing the package.

Note: You should have Go v1.11+

shmsr
  • 3,802
  • 2
  • 18
  • 29
  • Thanks... But I get a lot of error like this using this method levant/commands.go:7:2: cannot find package "github.com/hashicorp/levant/command" in any of: /opt/hostedtoolcache/go/1.14.7/x64/src/github.com/hashicorp/levant/command (from $GOROOT) /home/runner/go/src/github.com/hashicorp/levant/command (from $GOPATH) levant/commands.go:8:2: cannot find package "github.com/hashicorp/levant/version" in any of: /opt/hostedtoolcache/go/1.14.7/x64/src/github.com/hashicorp/levant/version (from $GOROOT) /home/runner/go/src/github.com/hashicorp/levant/version (from $GOPATH) – personalt Aug 22 '20 at 21:53
  • Where actually you're cloning this? Either do it outside of `GOPATH` or if you're cloning it inside `GOPATH`, then make sure to have a structure similar to: `$GOPATH/src/github.com/hashicorp/levant` and then try `go build ./...` – shmsr Aug 23 '20 at 03:57