go-modules

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: -

Does it make sense to add `go mod vendor` to a pre-commit hook?

拈花ヽ惹草 提交于 2021-02-07 10:59:35
问题 Setup: Our project is using golang 1.12.14 We are using go build -mod=vendor Issue: When new dependencies are added to go.mod the vendor folder isn't updated and people are committing code and forgetting to run go mod vendor to update the folder. My understanding is that since -mod=vendor specifies to use packages from the vendor folder, the go.mod file will have discrepancies from what we are actually using when building the project. Question: Should go mod vendor be added to a pre-commit

Why does go module ssh custom private repo (non-github) config still request https fetch?

柔情痞子 提交于 2021-01-29 15:35:00
问题 I am using Go modules. In order to use module version, I cannot use local module. For example: replace locakpkg => ../localpkg v0.1.0 The above will fail because replacement local path cannot have version so far (go 1.15). Thus, to make the module version work, I decided to use a private ssh repo. I did search how to make private ssh repo work for two days. By following many online articles, I did git config --global url.user@private.com:.insteadOf https://private.com/ go env -w GOPRIVATE

Referencing a Go module that is local [duplicate]

随声附和 提交于 2021-01-29 09:14:55
问题 This question already has answers here : How to use a module that is outside of “GOPATH” in another module? (2 answers) Closed 1 year ago . I've been unsuccessful in importing a package from a local project (a Go module). Here is a brief of what I'm trying: I created a Go module package like so: $ cd $ mkdir mymodule $ cd mymodule $ go mod init github.com/Company/mymodule Then I added hello.go under the mymodule with a little function // mymodule/hello.go package mymodule func sayHello()

How to make Go modules semantic import versioning v2+ work with vanity import path

自古美人都是妖i 提交于 2021-01-02 07:57:28
问题 We are trying to migrate our Go code base to go modules and I can't figure out how to make it work with vanity import paths. With dep Until now our dependency management tool has been dep . We would place a Gopkg.toml file in our project root, and would define a dependency like: [[constraint]] name = "mycompany.com/some-lib" version = "3.0.0" As you can see, we use a so-called vanity import path for our own packages. In fact, our code is actually hosted on a private git server altogether. So