go-modules

Two version of same dependency - lower version getting ignored

允我心安 提交于 2020-06-13 06:19:51
问题 I have a project in which two dependencies uses different version of same library. For instance, my project has dependency A and dependency B . A and B , both uses a common library/dependency X , but of different versions. A has v1 version of X and B has v2 version of X . So now when I add A & B as dependencies in my project, there are 2 versions of X in my project's go.sum . I was expecting, the respective versions will be referred at run time by A and B . But it is not the case. Somehow

How to set GOPRIVATE environment variable

半世苍凉 提交于 2020-06-09 11:15:24
问题 I started working on a Go project and it uses some private modules from Github private repos and whenever I try to run go run main.go it gives me a below 410 Gone error: verifying github.com/repoURL/go-proto@v2.86.0+incompatible/go.mod: github.com/repoURL/go-proto@v2.86.0+incompatible/go.mod: reading https://sum.golang.org/lookup/github.com/!repoURL/go-proto@v2.86.0+incompatible: 410 Gone I can easily clone private repo from terminal which means my ssh keys are configured correctly. I read

How to set GOPRIVATE environment variable

倖福魔咒の 提交于 2020-06-09 11:13:27
问题 I started working on a Go project and it uses some private modules from Github private repos and whenever I try to run go run main.go it gives me a below 410 Gone error: verifying github.com/repoURL/go-proto@v2.86.0+incompatible/go.mod: github.com/repoURL/go-proto@v2.86.0+incompatible/go.mod: reading https://sum.golang.org/lookup/github.com/!repoURL/go-proto@v2.86.0+incompatible: 410 Gone I can easily clone private repo from terminal which means my ssh keys are configured correctly. I read

go modules - replace does not work - replacement module without version must be directory path (rooted or starting with

陌路散爱 提交于 2020-05-29 05:52:13
问题 I just want to use a local package using go modules. I have these files in a folder goweb: and go.mod module goweb go 1.12 require mypack v0.0.0 replace mypack => ./src/mypack But go.mod complains: replacement module without version must be directory path (rooted or starting with . go get -u ./... go: parsing src/mypack/go.mod: open <local path>/goweb/src/mypack/go.mod: no such file or directory go: error loading module requirements So I am missing some path structure here 回答1: If your app

Module declared as X but was required as Y

房东的猫 提交于 2020-05-15 06:13:25
问题 I'm trying to use grafana/grafana/pkg/tsdb package in my module. I don't think this problem is specific to grafana but here it goes: $ go get -u github.com/grafana/grafana/pkg/tsdb go: finding github.com/inconshreveable/log15 latest go: finding github.com/go-macaron/session latest go: finding golang.org/x/oauth2 latest go: finding github.com/teris-io/shortid latest go: github.com/grafana/grafana/pkg/tsdb imports github.com/go-xorm/core: github.com/go-xorm/core@v0.6.3: parsing go.mod: module

Completely remove a package installed with “go get”?

随声附和 提交于 2020-02-26 02:16:34
问题 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 <PACKAGE_NAME> didn't seem to work, since there are files spread through, at least, these directories: ~/go/pkg/mod/github.com/<PACKAGE_NAME> ~/go/pkg/mod/cache/download/github.com/<PACKAGE_NAME> ~/go/pkg/mod/cache/download/sumdb/sum.golang.org/lookup/github.com/<PACKAGE_NAME> Is there a way to clean everything without removing all that manually? 回答1:

Completely remove a package installed with “go get”?

丶灬走出姿态 提交于 2020-02-26 02:15:06
问题 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 <PACKAGE_NAME> didn't seem to work, since there are files spread through, at least, these directories: ~/go/pkg/mod/github.com/<PACKAGE_NAME> ~/go/pkg/mod/cache/download/github.com/<PACKAGE_NAME> ~/go/pkg/mod/cache/download/sumdb/sum.golang.org/lookup/github.com/<PACKAGE_NAME> Is there a way to clean everything without removing all that manually? 回答1:

Go modules, private repos and gopath

戏子无情 提交于 2020-01-29 10:26:05
问题 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 "mycompany/mylib" ) func main() { fmt.Println("2+3=", lib.add(2, 3)) } $GOPATH/src/mycompany/myprogram/go.mod: module mycompany/myprogram (it doesn't have any dependencies; our real-world code does). $GOPATH/src/mycompany/mylib/lib.go: package mylib func Add(x int, y int)

How to Structure Golang Modules and Project structure in the New way

末鹿安然 提交于 2020-01-23 10:45:10
问题 It seems that the way modules are used since 1.11 has changed , and I am trying to understand how to reference a module / package from another directory. Lets say I have a folder structure \root\module1 \root\module2 I have a go.mod in each directory and I can access / use those modules from the \root directory How can I access module2 from module1. The modules are not published anywhere ( nor do I want them to be ) - I just want to access them. Module 2 contains types / structs that I need

How to Structure Golang Modules and Project structure in the New way

こ雲淡風輕ζ 提交于 2020-01-23 10:44:06
问题 It seems that the way modules are used since 1.11 has changed , and I am trying to understand how to reference a module / package from another directory. Lets say I have a folder structure \root\module1 \root\module2 I have a go.mod in each directory and I can access / use those modules from the \root directory How can I access module2 from module1. The modules are not published anywhere ( nor do I want them to be ) - I just want to access them. Module 2 contains types / structs that I need