Golang packaging: Difference between revisions

From wikinotes
Line 45: Line 45:
== Public Packages ==
== Public Packages ==
<blockquote>
<blockquote>
Packages are published/public by default.<br>
All published packages are public by default.<br>
You can <code>retract</code> package versions if you discovered a mistake.
You can <code>retract</code> package versions if you discovered a mistake.<br>
Official package publishing instructions [https://go.dev/doc/modules/publishing here].


<syntaxhighlight lang="bash">
# release preparation
go mod tidy
go test
git tag v0.0.1
git push origin v0.0.1
# publish
go list  # add your package to the index
</syntaxhighlight>
</blockquote><!-- Public Packages -->
</blockquote><!-- Public Packages -->



Revision as of 13:16, 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 Packages

Install Executable

Starting in golang-1.18, go install is used to install executables.

go install github.com/appliedgocode/goman@latest  # install latest goman executable

Public Packages

All published packages are public by default.
You can retract 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.1

# publish
go list  # add your package to the index

Private Packages

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.


Project Requirements

Module Requirements

See also go.mod file .

go mod graph       # show requirements tree
go mod tidy    # ensure go.mod matches src
go mod vendor  #
go get ...     # add requirement to go.mod

Vendoring