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
0
votes
1 answer

Go modules: "cannot find module providing package" importing sub package of a dependency

I have a project outside of $GOPATH and I want to use go mod. However, when I copy the code of from a project in $GOPATH and run $ GO111MODULE=on go mod init github.com/jgoc/modtest $ GO111MODULE=on go run main.go I get an error. go version…
Jess
  • 124
  • 1
  • 3
  • 6
0
votes
1 answer

Is there a way to build multiple Go module based projects at once?

Previous to using Go modules I could compile everything in my GOPATH with go build ./.... If I try this in the root of a directory with multiple module based Go projects, it doesn't download the dependencies specified in go.mod and fails to find the…
PiersyP
  • 5,003
  • 2
  • 33
  • 35
0
votes
1 answer

Go mod folders not found in Docker

I'm very new to go modules and am trying to take a project and update it to use them as they seem like a really great way to finally handle my dependencies. However, I'm having an issue getting things to build in Docker. I have a project with a…
LivingRobot
  • 883
  • 2
  • 18
  • 34
0
votes
2 answers

How to provide required go modules in code at the time of code commit and building application through drone.io?

I developed one go service and deployed it on GAE. At the time of developing this application, I included required go modules using command in my work machine- go get -u I am able to include other required go modules using following…
Aniruddha Dwivedi
  • 91
  • 1
  • 2
  • 13
0
votes
1 answer

How to make modules from golang.org appear with semver tags in my go.mod?

In my go.mod file. I wanna change versioning about modules from golang.org. they have commit date and hash after version. I'm using go mod, So I have go.mod file in my workspace. My go.mod is as follow. module myproject go 1.12.6 require ( …
Jay Lee
  • 119
  • 4
0
votes
1 answer

Error building Go project with /cmd structure (multiple entry points)

Here is the directory structure of my project (~/go/src/bitbucket.org/a/b): ├── cmd │   ├── c │   │   └── main.go │   └── d │   └── main.go ├── config │   ├── config.go │   ├── default.json │   └── development.json ├── go.mod ├── go.sum ├──…
ik9999
  • 33
  • 1
  • 5
0
votes
1 answer

How does go know where to get packages from

When I import a package in a go application (using modules and vscode with golang plugin): import ( cors "goa.design/plugins/cors/dsl" ) go automatically retrieves the package. How does go know where to get it from? I figured it simply pulls…
Dennie de Lange
  • 2,776
  • 2
  • 18
  • 31
0
votes
1 answer

Why are some packages in the code prefixed with v2, but the file path I cloned has no v2?

GitHub:https://github.com/filebrowser/filebrowser When I read the source code of this project, I found that main.go relied on the cmd package. I found that the path in the import statement contains v2, but I have no v2 in the file path after I…
Rain
  • 67
  • 1
  • 5
0
votes
1 answer

go module didn't download cgo soft links of dynamic library correctly

The environment is ubuntu 16.04 64bit, go version go1.12 linux/amd64 I am trying to switch my golang project from gopath to gomodule. One of the packages my project imported is using cgo to call ffmpeg, the package have several dynamic ffmpeg…
lihaichao
  • 45
  • 1
  • 3
0
votes
1 answer

Fix Go commands all giving "go: error loading module requirements"?

I am trying to install the dependencies for a Go project that uses Go modules. I have GO111MODULES=on in my environment. No matter what command I run (go build, go get, go clean --modcache, ...) it fails with output something like: sdgluck$ go build…
sdgluck
  • 24,894
  • 8
  • 75
  • 90
0
votes
1 answer

Is there a way to determine which functions are invoked from a go module during compilation?

I am writing a number AWS Lambda functions using Go. Common functionality is divided into modules, for example I have a module (M1) that provides an implementation of an interface with a backing store in terms of DynamoDB (so has a dependency on…
Anonimoak
  • 1
  • 1
0
votes
0 answers

Lines of code per binary overtime in Golang

In a single github repository containing multiple binaries code together. How can we find the total lines of codes per binary? Also, need to see the lines of codes per binary over a period of time. For example in the below repository…
Alok Kumar Singh
  • 2,331
  • 3
  • 18
  • 37
0
votes
4 answers

Where to find golang modules?

I am from node.js ecosystem. Golang has released its module system finally and I have read some articles about it: https://blog.golang.org/using-go-modules https://github.com/golang/go/wiki/Modules But, after that, I still didn't find a place…
Yao Zhao
  • 4,373
  • 4
  • 22
  • 30
0
votes
0 answers

Not able to build coredns project because of failure to fetch a dependency

I tried to build coredns https://github.com/coredns/coredns/ by cloning the repo in my gopath and running make, which produced the following error GO111MODULE=on go generate coredns.go GO111MODULE=on CGO_ENABLED=0 go build -v -ldflags="-s -w -X…
Palash Nigam
  • 1,653
  • 3
  • 14
  • 26
0
votes
1 answer

Copy html files to vendor folder

Use Case: I have Proj A and Proj B. Proj B depends on Proj A. I am using Go Modules for dependency management and go mod vendor for generating the vendor folder. Proj A is inside the vendor folder of Proj B. Issue: In Proj A, I have an HTML file.…
Sathesh
  • 6,323
  • 6
  • 36
  • 48