go-modules

How to remove an installed package using go modules

陌路散爱 提交于 2019-12-08 00:33:01
问题 I've installed a package using go modules (go get in Go 1.13) and now I want to remove it. In the documentation there is nothing about this and in go get docu neither. Removing the package from go.mod manually doesn't solve the issue so it remains in go.sum. How should I remove a package in a clean why? 回答1: Found it https://blog.golang.org/using-go-modules#TOC_7. go mod tidy So basically, once the package is not being imported in any package you can perform a go mod tidy and it will safely

What's the Go (mod) equivalent of npm-outdated?

穿精又带淫゛_ 提交于 2019-12-06 16:33:33
问题 I'd like to keep my go.mod dependencies up to date. With Node.js, I run the npm outdated (and later npm update ). What's the closest for Go mod? Ideally, I'd see a report of outdated dependencies of my project (not all recursively). Thanks 回答1: Listing direct and indirect dependencies This is detailed in Go 1.11 Modules: How to Upgrade and Downgrade Dependencies wiki: To view available minor and patch upgrades for all direct and indirect dependencies, run go list -u -m all . To upgrade to the

Using “go get” to download binaries without adding them to go.mod

爷,独闯天下 提交于 2019-12-05 01:49:47
问题 I'm using Go modules in my project and in my build system (e.g. Travis CI) I'm downloading a command-line utility (written in Go) with go get to assist with my build process, e.g.: go get github.com/mitchellh/gox However, this go get causes the file to be added to my go.mod file. This is contaminating the build environment, causing it to be "dirty" (since there are changes to some files tracked in git, in this case go.mod and go.sum), and I use git describe --always --dirty --tag to describe

go build keeps complaining that: go.mod has post-v0 module path

僤鯓⒐⒋嵵緔 提交于 2019-12-05 00:42:45
Following the release of Go 1.11, I have been trying to move my repositories to Go modules, by adding a go.mod file at their root. One of my root libraries my.host/root is in its version 17.0.1, so I wrote in its go.mod file: module my.host/root/v17 I tagged that version v17.0.1 as documented in the Go modules manual. When I try to make a new Go project that uses my root library, like: package main import root "my.host/root/v17" func main() { root.DoSomething() } And try to compile it, I get the following error: go: my.host/root@v0.0.0-20180828034419-6bc78016491a: go.mod has post-v0 module

What's the Go (mod) equivalent of npm-outdated?

血红的双手。 提交于 2019-12-04 21:54:02
I'd like to keep my go.mod dependencies up to date. With Node.js, I run the npm outdated (and later npm update ). What's the closest for Go mod? Ideally, I'd see a report of outdated dependencies of my project (not all recursively). Thanks Listing direct and indirect dependencies This is detailed in Go 1.11 Modules: How to Upgrade and Downgrade Dependencies wiki: To view available minor and patch upgrades for all direct and indirect dependencies, run go list -u -m all . To upgrade to the latest version for all direct and indirect dependencies of the current module: run go get -u to use the

Using “go get” to download binaries without adding them to go.mod

会有一股神秘感。 提交于 2019-12-03 16:58:36
I'm using Go modules in my project and in my build system (e.g. Travis CI) I'm downloading a command-line utility (written in Go) with go get to assist with my build process, e.g.: go get github.com/mitchellh/gox However, this go get causes the file to be added to my go.mod file. This is contaminating the build environment, causing it to be "dirty" (since there are changes to some files tracked in git, in this case go.mod and go.sum), and I use git describe --always --dirty --tag to describe my build, which shows up as "dirty". Is there a way to "go get" a binary just to download it, without

Module dependency caching issue during build

孤街醉人 提交于 2019-12-02 02:29:19
问题 Recently swapped to using Go 1.11 release and am trying to convert our projects over to using the new module system. However, I'm running into a frustrating issue with the caching system (I've thus far run with GOCACHE=off because of unrelated issues in the past, but that's not an option with modules). The below command log is based on using a fresh upgrade of my system Go to 1.11 using Homebrew (I typically use gvm to install and manage Go versions, but swapped to system build for this to

Module dependency caching issue during build

北城以北 提交于 2019-12-02 01:33:54
Recently swapped to using Go 1.11 release and am trying to convert our projects over to using the new module system. However, I'm running into a frustrating issue with the caching system (I've thus far run with GOCACHE=off because of unrelated issues in the past, but that's not an option with modules). The below command log is based on using a fresh upgrade of my system Go to 1.11 using Homebrew (I typically use gvm to install and manage Go versions, but swapped to system build for this to see if gvm was the issue). I set my GOPATH to a temporary directory and moved the source code out of the

How do I migrate from Dep to Go Modules

不羁岁月 提交于 2019-11-30 19:04:33
I'm currently using Dep and would like to start using Go modules. How do I migrate? Migrating from Dep to Go Modules is very easy. Run go version and make sure you're using version 11 or later. Move your code outside of GOPATH or set export GO111MODULE=on . go mod init [module path] : This will import dependencies from Gopkg.lock. go mod tidy : This will remove unnecessary imports, and add indirect ones. rm -rf vendor/ : Optional step to delete your vendor folder. go build : Do a test build to see if it works. rm -f Gopkg.lock Gopkg.toml : Delete the obsolete files used for Dep. Go has

How do I migrate from Dep to Go Modules

↘锁芯ラ 提交于 2019-11-30 03:04:04
问题 I'm currently using Dep and would like to start using Go modules. How do I migrate? 回答1: Migrating from Dep to Go Modules is very easy. Run go version and make sure you're using version 11 or later. Move your code outside of GOPATH or set export GO111MODULE=on . go mod init [module path] : This will import dependencies from Gopkg.lock. go mod tidy : This will remove unnecessary imports, and add indirect ones. rm -rf vendor/ : Optional step to delete your vendor folder. go build : Do a test