Questions tagged [go-modules]

A module is a collection of related Go packages. Modules are the unit of source code interchange and versioning. The go command has direct support for working with modules, including recording and resolving dependencies on other modules. Modules replace the old GOPATH-based approach to specifying which source files are used in a given build.

The Go Module concept was first published by Russ Cox here: Defining Go Modules.

Module support first appeared in Go 1.11 (in preliminary phase).

The go tool has built-in and extensive support for modules, documentation can be found at Go tool: Module maintenance and at Modules, module versions, and more. The command go help mod also provides sufficient details.

570 questions
134
votes
4 answers

Go update all modules

Using this module as an example (using a specific commit so others will see what I see): git clone git://github.com/walles/moar Set-Location moar git checkout d24acdbf I would like a way to tell Go to "update everything". Assume that the…
Zombo
  • 1
  • 62
  • 391
  • 407
128
votes
3 answers

missing go.sum entry for module providing package

Using the buffalo framework, after bootstraping it via buffalo new I am trying to run buffalo dev Expecting to see: project running on port 3000 But I am getting those error messages instead actions/app.go:4:2: missing go.sum entry…
Paulo
  • 8,690
  • 5
  • 20
  • 34
103
votes
4 answers

How to set GOPRIVATE environment variable

I started working on a Go project and it uses some private modules from Github private repos and whenever I try to run go run main.go it gives me a below 410 Gone error: verifying github.com/repoURL/go-proto@v2.86.0+incompatible/go.mod:…
UsamaAmjad
  • 4,175
  • 3
  • 28
  • 35
95
votes
3 answers

What does 'incompatible' in go.mod mean, will it cause harm?

I'm using goczmq in my project, something like next: main.go: package main import ( _ "github.com/zeromq/goczmq" ) func main() { } And more, I'm using golang 1.12 with gomod to manage my project. See next, I use go mod init xxx, and when…
atline
  • 28,355
  • 16
  • 77
  • 113
92
votes
4 answers

How to upgrade the go version in a go mod

What is the proper way to upgrade the go version in a go mod, specifically 1.13 to 1.14? Do you simply edit the go.mod file and change go 1.13 to go 1.14? I'm not asking about how to edit the go.mod file, I'm asking if it is proper to simply change…
James Haskell
  • 1,545
  • 2
  • 16
  • 21
64
votes
2 answers

Organize local code in packages using Go modules

I can not find a way to factor out some code from main.go into a local package when using Go modules (go version >= 1.11) outside of $GOPATH. I am not importing any external dependencies that need to be included into go.mod, I am just trying to…
TPPZ
  • 4,447
  • 10
  • 61
  • 106
61
votes
3 answers

How to remove an installed package using go modules

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…
jesugmz
  • 2,320
  • 2
  • 18
  • 33
58
votes
6 answers

go mod: cannot find module providing package

I am creating a go project with version 1.12.1. If I run GOPATH="$(pwd)/vendor:$(pwd)" GOBIN="$(pwd)/bin" go clean I get the following error: can't load package: package github.com/marvincaspar/go-example: unknown import path…
Marvin Caspar
  • 1,319
  • 1
  • 14
  • 25
48
votes
2 answers

what is the purpose of `go mod vendor` command?

The documentation says, The go mod vendor command constructs a directory named vendor in the main module's root directory that contains copies of all packages needed to support builds and tests of packages in the main module. Packages that are only…
Ahmad Ismail
  • 11,636
  • 6
  • 52
  • 87
47
votes
1 answer

What is the difference between go get command and go mod download command

I'm trying to get a good understanding of Go modules and am a bit puzzled by the difference between the go get command and the go mod download command. "The go get command updates module dependencies in the go.mod file for the main module, then…
JJ_programmer
  • 492
  • 1
  • 4
  • 6
46
votes
3 answers

How do I migrate from Dep to Go Modules

I'm currently using Dep and would like to start using Go modules. How do I migrate?
Nic
  • 12,220
  • 20
  • 77
  • 105
46
votes
2 answers

Go get cannot find local packages when using multiple modules in a repo

I'm having issues with go's new module system, as I'd like to define a local module and import it in the main program. The local package resides in a folder of the main package/root folder. Imagine the following project structure outside the…
Tobs.Core
  • 703
  • 1
  • 5
  • 12
43
votes
2 answers

How to use a module that is outside of "GOPATH" in another module?

I've created a library as the module for personal use outside of "GOPATH" in "database" folder with this command "go mod init database," and I don't know: How to use/import this module in another module? OS: Windows 7, Go: v1.11
samadadi
  • 3,100
  • 7
  • 25
  • 37
40
votes
4 answers

Manually fetch dependencies from go.mod?

I'm using go 1.11 with module support. I understand that the go tool now installs dependencies automatically on build/install. I also understand the reasoning. I'm using docker to build my binaries. In many other ecosystems its common to copy over…
Alex Guerra
  • 2,556
  • 3
  • 18
  • 24
36
votes
1 answer

Why there are two "require" blocks in go.mod since Go 1.17?

I've created a small go application. Few days back I've upgraded from go 1.15 to 1.17 and I've also upgraded packages with go get -u. After the changes I have 2 require blocks in my go.mod file. Why is it? What does it mean? Is it ok or something is…
jozo
  • 4,232
  • 1
  • 27
  • 29
1
2 3
37 38