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
-2
votes
2 answers

Cannot find package when running golang test

When I run go tests I get the error: cannot find package "github.com/stretchr/testify/assert" in any of: /usr/local/Cellar/go/1.17.6/libexec/src/github.com/stretchr/testify/assert (from $GOROOT) …
Andrew Smith
  • 483
  • 1
  • 3
  • 16
-2
votes
1 answer

can't load package: package golang.org/dl/go1.10.7@latest: can only use path@version syntax with 'go get' when trying to install another go version

I'm following this link to install and manage multiple versions of go in my ubuntu container. When I try to execute the command go install golang.org/dl/go1.10.7@latest, I get this error can't load package: package golang.org/dl/go1.10.7@latest: can…
-2
votes
1 answer

How to run tests in a multimodule Go project

I'm learning Go with the specialization Programming with Google Go. It has several courses, each of which has several modules. My project looks like the following (made with https://ascii-tree-generator.com/): google-golang/ ├─ .github/ │ ├─…
Abhijit Sarkar
  • 21,927
  • 20
  • 110
  • 219
-2
votes
2 answers

How to embed go.mod & go.sum in go 1.16

I want to embed a sub module directory in parent module, but golang remind me that pattern tpl/api_new/*: cannot embed file tpl/api_new/README.md: in different module I know that I can delete go.mod & go.sum and then run "go mod init && go get -u"…
-2
votes
1 answer

go mod init with private bitbucket repositories, contains disallowed path separator character ':'

Using: % go version go version go1.16.4 darwin/amd64 I've got a private bitbucket.org repository with a url like: git@bitbucket.org:chmorgan/some_repo.git Per the bitbucket url format you would do 'git clone…
Chris Morgan
  • 1,277
  • 1
  • 13
  • 33
-2
votes
1 answer

How to import the libraries in mongodb gridfs?

I am trying to work on MongoDB gridfs and I am new to it. I found online resources to make the gridfs work in golang and I found this article. When I took the code and tried to run it, it gave me the following error. Error could not import…
-2
votes
2 answers

Using a particular version for golang dependency module

I'm trying to build postfix-exporter code from the github link. It has a dependency on the go-systemd package as mentioned in go.mod file github.com/coreos/go-systemd/v22 v22.0.0. I see in the go.mod file , the mentioned version for the package is…
Learner
  • 1,544
  • 8
  • 29
  • 55
-2
votes
1 answer

Module name works improperly

There is a private git site with address of gitlab.myownsite.com, and the folder structure in the way of: /common |___ /libs |___ /lib_a |__ lib_a.mod /somethingelse Notice that, this is NOT folder structure of…
jean
  • 2,825
  • 2
  • 35
  • 72
-2
votes
1 answer

Permission denied creating /go directory in Jenkins when building a project that uses go modules

When I try to build a go Jenkins project that uses go modules, I see this error: go: writing go.mod cache: mkdir /go: permission denied I also see a similar error for every import: project-name/cmd imports …
AlexPogue
  • 757
  • 7
  • 14
-2
votes
1 answer

How to add go pkg to existing repo?

I have this repo in github that have library for cpp and go in same repo. Now how can I create go.mod in the go to import it ? I searched google about that but all are have Separate repo. How can i do it ? Thanks.
srilakshmikanthanp
  • 2,231
  • 1
  • 8
  • 25
-2
votes
1 answer

how to find out which git-branch a dependency in go.mod belongs to by command-line?

I want to write a shell program to check whether all go module dependencies in my project are on newest master version in their repositories. In particular, I want to know which branch each module is on. There is a file "go.mod" containing each…
classSalt
  • 11
  • 1
-2
votes
1 answer

Does go modules provide a mechanism like maven's scope?

Saying I'm developing a plugin p of a system A, so p naturally depends on A when developing and testing. But this kind of dependency is not necessary once p integrated with A. In maven the dependency can be claimed with a provided scope to avoid…
Yalou Wang
  • 265
  • 2
  • 6
-2
votes
1 answer

Is it possible to update local packages without running go install?

I am trying to import a local file into my main.go file and this tutorial (and other similar tutorials) says to run go install in order to import that path as a package. This seems like a slow way to develop local packages because you would…
sdfsdf
  • 5,052
  • 9
  • 42
  • 75
-2
votes
1 answer

Should I use go modules in production

I am using dep, but I am quite seduced by built-in Go Modules in Go 1.11 In the docs, it says: Go 1.11 includes preliminary support for versioned modules as proposed here. Modules are an experimental opt-in feature in Go 1.11, with the plan of…
Juliatzin
  • 18,455
  • 40
  • 166
  • 325
-3
votes
1 answer

I can't activate GO111MODULE

I want to use go modules, after a lot of searching, I just saw some website that said, enable go111module with this command: GO111MODULE=on But it's not a path variable, it does not even exist on my pc, so it shows me GO111MODULE is not recognized…
Arsham Arya
  • 1,461
  • 3
  • 17
  • 25
1 2 3
37
38