TL;DR move your code outside of GOPATH : this will import dependencies from . go mod init [module path] Gopkg.lock : this will remove unnecessary imports, and add indirect ones. go mod tidy rm -fr vendor/ : is everthing ok? go build rm -f Gopkg.lock Gopkg.toml git commit -m 'chore(dep): migrated from dep to Go 1.11 modules' Introduction Before Go 1.11, dependency was left to the . There was many solutions, but my favorite was . management community dep Like many dependency management tools from other languages, has a file for dependencies requests ( ), a file to lock the exact versions used ( ), and a directory to hold the dependency files. A simple command is doing all the work. dep Gopkg.toml Gopkg.lock vendor [dep ensure](https://golang.github.io/dep/docs/daily-dep.html) Also, before Go 1.11, you project source needed to be inside your and you had to respect a . GOPATH workspace layout Fortunately, with Go 1.11, your code can live anywhere on your disk! Also, dependency management is handled by the command, with the introduction of . go modules Migration After installing Go 1.11, start by moving your code outside of : GOPATH (my was ) GOPATH ~/code/go/ ~/code $ mv go/src/gitlab.callr.tech/platform/asterisk-pbx-agi . Now, my project is at . ~/code/asterisk-pbx-agi Let’s try : go mod init ~/code/asterisk-pbx-agi $ go mod init go: cannot determine module path for source directory ~/code/asterisk-pbx-agi (outside GOPATH, no import comments) Ah. So because the code is outside , go cannot determine the “module path” anymore. Makes sense. GOPATH Let’s try again with a module path: ~/code/asterisk-pbx-agi $ go mod init gitlab.callr.tech/platform/asterisk-pbx-agigo: creating new go.mod: module gitlab.callr.tech/platform/asterisk-pbx-agigo: copying requirements from Gopkg.lock Go has imported my dependencies from by reading the file. Neat. It also created a file: dep Gopkg.lock go.mod module gitlab.callr.tech/platform/asterisk-pbx-agirequire ( github.com/zaf/agi v0.0.0-20160319110841-15f1ed9d87e3 go.uber.org/atomic v1.3.2 go.uber.org/multierr v1.1.0 go.uber.org/zap v1.8.0 gopkg.in/yaml.v2 v2.2.1) At this point, a should work. go build But let’s try a first. Here is after running it: go mod tidy go.mod module gitlab.callr.tech/platform/asterisk-pbx-agirequire ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/pkg/errors v0.8.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/stretchr/testify v1.2.2 // indirect github.com/zaf/agi v0.0.0-20160319110841-15f1ed9d87e3 go.uber.org/atomic v1.3.2 // indirect go.uber.org/multierr v1.1.0 // indirect go.uber.org/zap v1.8.0 gopkg.in/yaml.v2 v2.2.1) Interesting. has detected that some dependencies were “indirect” and marked them as such. It also added some other ones, needed for . go mod tidy go test When both and work, you can safely remove the old files: go build go test ~/code/asterisk-pbx-agi $ rm -fr Gopkg.* vendor/ And you’re done. Updating your CI Using Gitlab, here is how we used to build with Go 1.10 and dep: Build Go: image: golang:1.10 stage: build script: - curl -fsSL -o /usr/local/bin/dep https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64 && chmod +x /usr/local/bin/dep - ln -s `pwd` /go/src/asterisk-pbx-agi - cd /go/src/asterisk-pbx-agi - dep ensure -vendor-only - GOOS=linux GOARCH=amd64 go build -ldflags "-linkmode external -extldflags -static" -a -o callr.agi artifacts: paths: - callr.agi expire_in: 1 week Because of the mess, we had to create a link to the code inside , and run and inside it. GOPATH /go/src dep go build After Here is the same task with Go 1.11: Build Go: image: golang:1.11 stage: build script: - GOOS=linux GOARCH=amd64 go build -ldflags "-linkmode external -extldflags -static" -a -o callr.agi artifacts: paths: - callr.agi expire_in: 1 week Much simpler. will handle the dependencies automatically. go build Documentation Go wiki modules Go command doc Originally published at blog.callr.tech on September 11, 2018.