There are many ways you can share Go code and applications. Here are a few.
publishing to the Go package index (pkg.go.dev)
This allows anyone with Go installed to download your package with go get
or go install
. go get
is for getting code, and go install
is for installing executables. More details on those commands are in the Go docs and this Stack Overflow discussion.
Here are the official docs on publishing to pkg.go.dev:
- Publishing Go Modules
- Publishing a module
- The PowerShell equivalent of the command in step 6 is
$env:GOPROXY="proxy.golang.org" && go list -m example.com/mymodule@v0.1.0
- The PowerShell equivalent of the command in step 6 is
The package may take some time to appear in the package index because the servers are not always running at 100%. If you want to, you may be able to speed up indexing by searching for your package at pkg.go.dev, or especially by using go get
on the package.
Homebrew and Snap
Although I haven’t tried it myself, this repo appears to be a good example of how to automatically publish to the Homebrew and Snap package managers.
as executable files (binaries)
In many cases, it’s super easy to create and publish Go executables for all major platforms using GoReleaser and the GoReleaser GitHub Action. You can see an example of the result here. If you publish your executables on the web, you may want to also submit the Windows executable(s) to Microsoft for malware analysis as a software developer to try to prevent users from getting the Windows Defender SmartScreen warning.