![]() ![]() $ go get gobin is a module-aware command to install or run binaries that provides additional flexibility, including the ability to install without altering your current module's go.mod In short, with Go 1.12 or 1.13, the simplest solution is to cd to a directory without a go.mod, such as: $ cd /tmp You want to install a tool, but you don't want to modify your current go.mod to track that tool as a dependency. There are at least two cases to consider: Case 1 Several of the other answers here have grown stale at this point. However, there's a PR open for Go 1.12 that, if accepted, will allow go get to simply work while outside a module, even with GO111MODULE=on set. Little in the way of established consensus as of yet. Long-term, figuring out what the best solution is to support tool install via go get (or another command, like go install with a flag) is an ongoing area of discussion with This explicitly disables the module support, even if you're in a module package currently, and forces it to only utilize your GOPATH. ![]() The solution, short term, is to run GO111MODULE=off go get. This is a known and heavily debated issue: If the GO111MODULE var is set to on, you have to be inside an initialized go module directory tree in order to use go get, even if you're trying to get a tool rather than a new dependency. Please see this answer, and the ones it links to, for details of handling this situation in Go 1.12 and later. Since the release of Go 1.12, this is no longer accurate. Edit: The original answer herein referred specifically to the state of the tooling in Go 1.11. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |