vgo

How can I persist go 1.11 modules in a Docker container?

大城市里の小女人 提交于 2021-02-07 13:16:55
问题 I am migrating a Go 1.10 app to Go 1.11. This also includes migrating from dep to mod for managing dependencies. As the application depends on a database, I am using a docker-compose to set up the local development environment. With Go 1.10 I simply mounted the local repository (including the vendor folder) into the correct location in the container's GOPATH : web: image: golang:1.10 working_dir: /go/src/github.com/me/my-project volumes: - .:/go/src/github.com/me/my-project environment: -

How can I persist go 1.11 modules in a Docker container?

扶醉桌前 提交于 2021-02-07 13:12:52
问题 I am migrating a Go 1.10 app to Go 1.11. This also includes migrating from dep to mod for managing dependencies. As the application depends on a database, I am using a docker-compose to set up the local development environment. With Go 1.10 I simply mounted the local repository (including the vendor folder) into the correct location in the container's GOPATH : web: image: golang:1.10 working_dir: /go/src/github.com/me/my-project volumes: - .:/go/src/github.com/me/my-project environment: -

How to remove an installed package using go modules

陌路散爱 提交于 2019-12-08 00:33:01
问题 I've installed a package using go modules (go get in Go 1.13) and now I want to remove it. In the documentation there is nothing about this and in go get docu neither. Removing the package from go.mod manually doesn't solve the issue so it remains in go.sum. How should I remove a package in a clean why? 回答1: Found it https://blog.golang.org/using-go-modules#TOC_7. go mod tidy So basically, once the package is not being imported in any package you can perform a go mod tidy and it will safely

Accessing local packages within a go module (go 1.11)

被刻印的时光 ゝ 提交于 2019-12-02 16:12:15
I'm trying out Go's new modules system and am having trouble accessing local packages. The following project is in a folder on my desktop outside my gopath. My project structure looks like: / - /platform - platform.go - main.go - go.mod // platform.go package platform import "fmt" func Print() { fmt.Println("Hi") } // main.go package main import "platform" func main() { platform.Print() } go build main.go tells me cannot find module for path platform I would strongly suggest you to use go toolchain which takes care of these issues out of the box. Visual Studio Code with vscode-go plugin is

Where is the module cache in golang?

血红的双手。 提交于 2019-11-30 14:34:59
问题 When I enable gomodules and build my go program then the required packages are downloaded. But I cannot find them in $GOPATH/src/ or in $GOPATH/src/mod . Where are they stored? export GO111MODULE=on go mod init go build main.go go: finding github.com/sirupsen/logrus v1.0.6 go: downloading github.com/sirupsen/logrus v1.0.6 ... 回答1: For Go 1.11, they are stored in $GOPATH/pkg/mod 回答2: I'm on Macos 10.13.6, using go1.11 darwin/amd64 and echo $GOPATH is empty. I found my modules in $HOME/go/pkg

Where is the module cache in golang?

a 夏天 提交于 2019-11-30 11:14:48
When I enable gomodules and build my go program then the required packages are downloaded. But I cannot find them in $GOPATH/src/ or in $GOPATH/src/mod . Where are they stored? export GO111MODULE=on go mod init go build main.go go: finding github.com/sirupsen/logrus v1.0.6 go: downloading github.com/sirupsen/logrus v1.0.6 ... For Go 1.11, they are stored in $GOPATH/pkg/mod I'm on Macos 10.13.6, using go1.11 darwin/amd64 and echo $GOPATH is empty. I found my modules in $HOME/go/pkg/mod The module cache is stored in $GOPATH/pkg/mod , or $HOME/go/pkg/mod if $GOPATH is not set. Note : in general,

Accessing local packages within a go module (go 1.11)

白昼怎懂夜的黑 提交于 2019-11-28 16:40:36
问题 I'm trying out Go's new modules system and am having trouble accessing local packages. The following project is in a folder on my desktop outside my gopath. My project structure looks like: / - /platform - platform.go - main.go - go.mod // platform.go package platform import "fmt" func Print() { fmt.Println("Hi") } // main.go package main import "platform" func main() { platform.Print() } go build main.go tells me cannot find module for path platform 回答1: I would strongly suggest you to use

How do I resolve “cannot find module for path X” importing a local Go module?

淺唱寂寞╮ 提交于 2019-11-28 08:48:24
In my Go project, I want to break out some generic functionality into a Go module, separate from the main project. I'm doing this outside of GOPATH in keeping with go's future. I don't want to publish the module on GitHub or anywhere else. All my attempts to import this module into the main project result in: cannot find module for path X I've run go mod init X in the module's folder. The contents of its go.mod file is: module X Building or installing this module seems to do nothing. I've found no sign of it in $GOPATH/pgk/mod . I've tried a variety of import statements: import "X" import "..

How do I resolve “cannot find module for path X” importing a local Go module?

≡放荡痞女 提交于 2019-11-27 19:19:28
问题 In my Go project, I want to break out some generic functionality into a Go module, separate from the main project. I'm doing this outside of GOPATH in keeping with go's future. I don't want to publish the module on GitHub or anywhere else. All my attempts to import this module into the main project result in: cannot find module for path X I've run go mod init X in the module's folder. The contents of its go.mod file is: module X Building or installing this module seems to do nothing. I've