How to remove an installed package using go modules

Found it https://go.dev/blog/using-go-modules#removing-unused-dependencies 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 remove the unused dependencies. And if you are vendoring the dependencies, then run the command below to make the module changes be applied in the vendor … Read more

How to upgrade the go version in a go mod

Command go: Edit go.mod from tools or scripts: Usage: go mod edit [editing flags] [go.mod] Edit provides a command-line interface for editing go.mod, for use primarily by tools or scripts. It reads only go.mod; it does not look up information about the modules involved. By default, edit reads and writes the go.mod file of the … Read more

Go update all modules

tl;dr; this is what you want: go get -u go mod tidy and to recursively update packages in any subdirectories: go get -u ./… The inconsistencies you are seeing is due to the inherent organic nature of software. Using your example, commit d24acdbf of git://github.com/walles/moar most likely was checked in by the maintainer without running … Read more

How to set GOPRIVATE environment variable

Short Answer: go env -w GOPRIVATE=github.com/repoURL/private-repo OR If you want to allow all private repos from your organization go env -w GOPRIVATE=github.com/<OrgNameHere>/* Long Answer: Check “Module configuration for non-public modules” for more information: The GOPRIVATE environment variable controls which modules the go command considers to be private (not available publicly) and should therefore not use … Read more