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

How to deal with dependencies of the package under vendor folder in golang?

I am building a go binary and it is using go module through vendor to manage the dependencies. But each time I am building the binary an error like "proto.IsVersion3" is presented. Now I think this may be because the dependency under vendor doesn't…
No9527
  • 31
  • 9
-1
votes
1 answer

Does go mod require you to pull an entire module, including transitive dependencies?

If I have a simple import such as: import ( "hello.io/example/client" ) ... should I assume that go mod tidy by definition, will try to “import” (or more precisely transitively resolve) all of hello.io/example/ ? Details In my case, I only…
jayunit100
  • 17,388
  • 22
  • 92
  • 167
-1
votes
1 answer

Import module located in sub folder in Goland IDE

How can I get Goland to lint my go.mod correctly and not report "missing dependency" errors for a module I am maintaining in a sub directory of my main project? I'm trying to follow the pattern in hashicorp's vault project where I maintain an api…
ben schwartz
  • 2,559
  • 1
  • 21
  • 20
-1
votes
1 answer

Golang modules: Import proto definitions

I am trying to learn Go modules dependency manager but getting an error while importing auto-generated proto definitions. Have been struggling with this for 2 days. Any help will be greatly appreciated. Directory structure: ➜ ~/go-service-skeleton>…
Yashesh
  • 91
  • 8
-1
votes
1 answer

Golang cannot import a forked repository

I'm extending an existing database driver (https://github.com/MonetDB/MonetDB-Go). I use the github url as an import in my main.go, and in the go.mod: replace github.com/fajran/go-monetdb@latest => github.com/MonetDB/MonetDB-Go v1.0.0 Yet when I try…
MitchellWeg
  • 49
  • 1
  • 7
-1
votes
1 answer

go resolve (not yet) remote dependencies during development

I'm developing a go module, let's call it github.com/spyna/mymodule. This module is a library and another go project uses it, for example: github.com/spyna/goapp uses github.com/spyna/mymodule. During the development phase, I don't want to push…
Spyna
  • 490
  • 3
  • 12
-1
votes
1 answer

Is it possible to dis-allow import of module (mono-repo), having multiple independent modules?

What I essentially have is a mono-repo, which doesn't have a go.mod at the root level. There are multiple directories inside this mono-repo, with each of them having their own go.mod files. I'll refer to them as sub-modules. Now, I've figured out a…
-1
votes
1 answer

How to get sub-dependencies of a dependency added as a git submodule

Let's say I am working on a Go project, called X, which has a dependency upon a repo Y. I am not using go mods in my project X yet. I have now added Y as a git submodule in my project X in the vendor pkg using the following command: git submodule…
Rajvir
  • 108
  • 7
-1
votes
2 answers

How to update a go dependency with different module name than src path?

The location: github.com/elastic/beats The mod file: github.com/elastic/beats/go.mod The module name: github.com/elastic/beats/v7 The tag: v7.10.2 What LoTR incantation of go get to I have to run to get a little dependency update action?
bschaeffer
  • 2,824
  • 1
  • 29
  • 59
-1
votes
2 answers

go run doesnt get the latest tag

I'm playing with GraphQL in Go and I was trying to get gqlgen tool using the familiar go run command. I was expecting it to retrieve the latest available tag, instead I"m somehow getting a tag which does not seem to exist in the repo at all: $ go…
milosgajdos
  • 851
  • 1
  • 14
  • 32
-1
votes
2 answers

Where is the go project working directory when using modules?

I am trying to download, make some tweaks and build a golang project from GitHub. The project's instructions are: go get github.com// cd src/github.com// go build . That used to work in the past — before…
Greendrake
  • 3,657
  • 2
  • 18
  • 24
-1
votes
1 answer

How to create proxy for golang package sources

Let's say I have all source code for module hosted on github.com/example/my-module. But I want to create a proxy hosted on example.com/my-module to redirect all requests to github.com/example/my-module and use my custom domain name in…
Kirill
  • 7,580
  • 6
  • 44
  • 95
-1
votes
1 answer

Importing local go module of external service

The background: Two Applications - A and B Application 'A' contains two go.mod files A/pkg/test/go.mod: (I keep here application specific structures which are gonna be reused by another services willing to integrate) module A/pkg/test go…
Power
  • 141
  • 1
  • 11
-1
votes
1 answer

get error unknown revision depency during go mod download

i just clone a new repo and after it finish, i run go mod download and then i got error like this go: github.com/micro/go-micro/v2@v2.9.1 requires github.com/go-acme/lego/v3@v3.4.0 requires github.com/google/go-querystring@v1.0.0: reading…
pocket k
  • 1
  • 2
-1
votes
1 answer

Use GOPATH in golang makefile or init go mod first?

I'm learning to write Golang makefile and got some confused me because some examples they config GO env such as GOOS, GOPATH, GOBASE before building. But normally I can use go mod init to create go module and in Makefile use go build to build my…
Quang
  • 135
  • 2
  • 9