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
35
votes
8 answers

Go modules: checksum mismatch

I recently started using modules in Go, but I frequently encounter issues where everything works fine on one machine, but a checksum mismatch is encountered when building the codebase on another machine. The issue always concerns the same third…
edwardmp
  • 6,339
  • 5
  • 50
  • 77
30
votes
6 answers

malformed module path "xxxx/xxxx/uuid" missing dot in first path element when migrating from GOPATH based dep to go mod

$ go version 1.13.3 I have a folder structure as follows: GOPATH +---src +--- my-api-server +--- my-auth-server +--- main.go +--- my-utils +--- uuid +---…
Ayush Gupta
  • 8,716
  • 8
  • 59
  • 92
30
votes
2 answers

How to serve documentation using godoc together with go modules?

It seems that the godoc tool is not Go modules aware. A simple godoc -goroot=. serves the project files, but it does not generate documentation for the packages. I tested it from withing the projects source directory, where also the go.mod and…
Simon Schürg
  • 2,134
  • 2
  • 20
  • 31
29
votes
7 answers

go modules installing go tools

I'm using go modules as dependency management, and I'm having problem to install something like this: go get -u github.com/go-critic/go-critic/... the result from above was: go: cannot find main module; see 'go help modules'
Luis.at.code
  • 299
  • 1
  • 3
  • 6
28
votes
3 answers

Go modules, private repos and gopath

We are converting our internal codebase from the dep dependency manager to go modules (vgo or built in with go1.11.2). Imagine we have code like this: $GOPATH/src/mycompany/myprogram/main.go: package main import ( "fmt" lib…
diagprov
  • 443
  • 1
  • 4
  • 8
27
votes
1 answer

Difference between go mod download and go mod tidy

What is the different between go mod download and go mod tidy? When I run go mod tidy, if the import is not found it also downloads it.
dave
  • 867
  • 1
  • 5
  • 11
24
votes
3 answers

What are the benefits of having a vendor folder?

I can't really grasp the purpose of having a vendor folder. Based on what I learned, it seems the vendor folder is only beneficial if you're trying to make your repo compatible with golang versions earlier than 1.11. We are running golang…
Daniel Kobe
  • 9,376
  • 15
  • 62
  • 109
23
votes
2 answers

Go Modules vs Package

just starting to learn about Go Modules. I have a question on importing local packages inside the same module. The example I am looking at is this repo: https://github.com/Azure/azure-service-bus-go The module is module…
Yana K.
  • 1,926
  • 4
  • 19
  • 27
23
votes
4 answers

Could not import local modules in Golang

I am trying to import local modules, but I am unable to import it using go mod. I initially built my project using go mod init github.com/AP/Ch2-GOMS Note my environment is go1.14 and I am using VSCode as my editor. This is my folder…
Ayman Arif
  • 1,456
  • 3
  • 16
  • 40
22
votes
2 answers

Completely remove a package installed with "go get"?

I'm using Go 1.13.1, latest as of today. I'm trying to completely remove a package that I installed with go get from GitHub. The go clean -i didn't seem to work, since there are files spread through, at least, these…
rodrigocfd
  • 6,450
  • 6
  • 34
  • 68
22
votes
5 answers

Go Modules: finding out right pseudo-version (vX.Y.Z--) of required package

I am trying out Go modules. My project requires the libarary golang.org/x/net/html, so I defined this go.mod file: module github.com/patrickbucher/prettyprint require golang.org/x/net/html And wrote this demo program to check if the dependency…
Patrick Bucher
  • 1,302
  • 2
  • 14
  • 36
22
votes
1 answer

How do I find the Go module source cache?

I've upgraded a project to Go 1.11 and enabled module support for my project, but it seems that CircleCI is re-downloading the dependencies on every build. I know CircleCI allows caching between rebuilds, so I've looked at the documentation for Go…
Rob G.
  • 243
  • 1
  • 2
  • 8
21
votes
2 answers

How do I refactor module name in Go?

I have a Go module named mymodule, and I'd like to rename it into github.com/hylowaker/awesome-module Using command go mod edit -module github.com/hylowaker/awesome-module only changes module name in go.mod file, leaving go sources unchanged. I…
hylowaker
  • 966
  • 2
  • 9
  • 24
21
votes
2 answers

How to use a forked module, with versioned Go Modules (v1.11+, GO111MODULE=on)

I forked a go module, and want to use the fork in my project that uses versioned modules via v1.12. My code is not inside my GOPATH. My project's go.mod: module github.com/me/myproj go 1.12 require ( …
rynop
  • 50,086
  • 26
  • 101
  • 112
20
votes
2 answers

module lookup disabled by GOPROXY=off, but go env shows GOPROXY is set

When trying to lookup some modules, I am having an issue from VS Code where the error pictured below indicates that my GOPROXY is set to off, but when I run go env, I see that GOPROXY is actually…
1
2
3
37 38