Golang packaging: Difference between revisions
From wikinotes
Line 49: | Line 49: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Package Management --> | </blockquote><!-- Package Management --> | ||
= Publishing Modules = | = Publishing Modules = |
Revision as of 13:54, 19 June 2022
Documentation
private modules https://go.dev/ref/mod#private-modules module proxies https://go.dev/ref/mod#module-proxy module cache https://go.dev/ref/mod#module-cache
Locations
go module index https://index.golang.org/index go checksum index https://sum.golang.org/
Locations
~/go/bin
default $GOBIN
path, where go executables are installed
OS Package Management
Installing Packages
# golang < 1.18 go get -u example.com/x/foo # golang >= 1.18 go install example.com/x/foo@latestUninstalling Packages
# there doesn't seem to be a managed way of doing this rm ${GOBIN:=~/go/bin}/tool-to-delete
Publishing Modules
Public Modules
All published packages are public by default.
You canretract
package versions if you discovered a mistake.
Official package publishing instructions here.Release Preparation
go mod tidy go test git tag v0.0.1 git push origin v0.0.1Publishing your package
# adds your package to the index go list # add specific module-version to a specific-index GOPROXY=proxy.golang.org \ go list \ -m example.com/mymodule@v0.1.0Private Modules
Go executables are installed/built from src.
You'll need to add your package to$GOPRIVATE
envvar to stop it from being indexed.
While unset$GONOPROXY
and$GONOSUMDB
, will fall back on$GOPRIVATE
.
Otherwise you'll want to set these to prevent your packages from getting added to the index.