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

package handlers/gql.go is not in GOROOT (/usr/local/go/src/handlers/gql.go)

I am trying to import local packages, I have done this before with go in my other projects. I am not sure If I am doing something wrong or I broke something in the environment I have tried go 1.14 && 1.15. go mod init…
Malikiah
  • 149
  • 2
  • 2
  • 13
-1
votes
1 answer

Update the library to a specific version

This is the version of golang.org/x/net library I am using golang.org/x/net v0.0.0-20181005035420-146acd28ed58 v0.0.0 is a release(it means there is no release) 20181005 is the time for commit 146acd28ed58- short for commit id what is 035420 in the…
Oktay Alizada
  • 290
  • 1
  • 6
  • 19
-1
votes
1 answer

How to set go module path of private repository

I want to set my go module path to example.com/myrepo instead of github.com/myusername/myrepo such that I am able to import in inside another repository. for example, if my go.mod looks like this module example.com/myrepo go 1.13 how will I make…
Amit Basuri
  • 563
  • 5
  • 12
-1
votes
1 answer

Compilation error when using local dependencies from vendor directory

Build (Fails): GO111MODULE=off go build -o diameter [pceuser@pincb-brm02 src]$ echo $GOPATH /home/pceuser/policy-control-engine [pceuser@pincb-brm02 src]$ pwd /home/pceuser/policy-control-engine/src [pceuser@pincb-brm02 src]$ ls backupgx…
-1
votes
1 answer

File paths for running golang code for debug vs run

I have a golang code on Linux VM which I am remotely debugging using VS Code. Below is my folder structure MainFolder |__Config |__Other folders Other Files When I run the code using VS debugger, it runs properly and my code is able to find…
Chaitanya Gadkari
  • 2,669
  • 4
  • 30
  • 54
-1
votes
1 answer

Where is `go build` getting its code from?

So I have a project that I want to use some bit of pieces of the Docker CLI code for. It uses modules. Docker CLI does not. The weird thing is, that at some point I had this working, but I had to switch branches and now I cannot get it to build…
-1
votes
1 answer

Why go build/install updates required packages automatically?

I have an issue with the current version of the grpc-go package. So I want to use the previous version of the package. I used the following command to change the required version: go get google.golang.org/grpc@v1.26.0 But now when I want to use go…
micharaze
  • 957
  • 8
  • 25
-1
votes
3 answers

Go build failure: "Downloaded inconsistent tile" when running "go build" with go mod file

I'm just starting a project and want to use go modules. I've created a new repo with a small amount of functionality, but it refuses to build. I have tested go build without modules and it works just fine. Error…
Gregory Ledray
  • 989
  • 7
  • 19
-1
votes
1 answer

how to migrate already exist golang project from go path to go module

i have an already exist golang project want to migrate it to go mod, i followed this article migrate to go modules but the problem here is i get this error every time i try to run or build the project cannot load go-temp/pkg/custom_package:…
Ali Bedaer
  • 395
  • 1
  • 4
  • 12
-1
votes
2 answers

Get latest version in go.mod if one of the requires is +incompatible

I have go.mod file, with require, one of them if github.com/mattermost/mattermost-server v5.11.1+incompatible but there is a new version of library in github, 5.17.1. I download latest version and work with it, but when i run go mod init my go.mod…
godvlpr
  • 141
  • 1
  • 3
  • 11
-1
votes
1 answer

Can't import a package from a different file in GO

I am using go1.13.4 and below is my project structure: src/types/type.go src/utils/util.go go.mod In go.mod: module example.com/graphql go 1.13 require github.com/graph-gophers/graphql-go v0.0.0-20191031232829-adde0d0f76a3 In…
Joey Yi Zhao
  • 37,514
  • 71
  • 268
  • 523
-1
votes
2 answers

Go library: cannot find module providing package lib

I am creating 3 separate go projects: ace, aces-client and a library shared by both projects aceslib. I am having trouble including the shared library according to the go-documentation (https://golang.org/doc/code.html#Library) all go files in…
yulivee
  • 307
  • 2
  • 10
-1
votes
1 answer

Problem when trying to use local submodules

I'm trying to use go modules with some local code that hasn't been pushed to github yet (golang version is 1.12.7) So far I have 3 modules that are all under the same parent root (sibiling folders). maps and go-database-util are already pushed, but…
Lucia
  • 1
  • 2
-2
votes
2 answers

How to prevent GoLand from deleting "github.com/fxamacker/cbor/v2" on save?

Some Go text editors and IDEs (in my particular case, JetBrains's GoLand IDE) will automatically delete unused imports on save. This is ordinarily a good thing, because the Go compiler throws errors for unused imports. However, in the case of the…
Shane Bishop
  • 3,905
  • 4
  • 17
  • 47
-2
votes
1 answer

How to use a customize go mod while installing GO?

I need to use go 1.17.9. mod file However I need to use a different ( lower ) version of "golang.org/x/net" package, not the one specified in mod file. How would I go about it i.e. are there commands to edit go.mod and re-fetch the desired versions…
JavaDeveloper
  • 5,320
  • 16
  • 79
  • 132