Automated Go installer — unattended, cross-platform, version-pinned (1.25.2 by default).
Installs Go following the official instructions at https://go.dev/doc/install
curl -fsSL https://raw.githubusercontent.com/tinywasm/goinstall/main/scripts/install.sh | sudo bash -s 1.25.2$env:GO_VERSION="1.25.2"; irm https://raw.githubusercontent.com/tinywasm/goinstall/main/scripts/install.ps1 | iexhash -r # Linux/macOS: clear shell cache (once per terminal)
go version # expected: go version go1.25.2On Windows, open a new PowerShell window — the MSI updates PATH in the registry and the current window does not pick up the change.
- Detects OS (
linux/darwin) and architecture (amd64/arm64) - Downloads
go1.25.2.OS-ARCH.tar.gzfromhttps://go.dev/dl/ - Removes any existing
/usr/local/go - Extracts the archive to
/usr/local - Creates symlink:
/usr/local/bin/go->/usr/local/go/bin/go - Verifies with
go version - Deletes the downloaded archive
- Downloads
go1.25.2.windows-amd64.msifromhttps://go.dev/dl/ - Runs the MSI installer silently (
/quiet /norestart) - Verifies with
go version - Deletes the downloaded MSI
If you prefer to inspect the script before running:
git clone https://github.com/tinywasm/goinstall.git
cd goinstall
# Linux/macOS
sudo bash scripts/install.sh
# Windows (PowerShell as Admin)
.\scripts\install.ps1Use goinstall from another Go package to ensure Go is installed before running further setup:
import "github.com/tinywasm/goinstall"
// Ensure Go 1.25.2 is installed
goPath, err := goinstall.EnsureInstalled()
// With options
goPath, err := goinstall.EnsureInstalled(
goinstall.WithVersion("1.25.2"),
goinstall.WithLogger(func(msg string) { fmt.Println(msg) }),
)
// Chain another installer after Go is ready
goPath, err := goinstall.EnsureInstalled(
goinstall.WithAfterInstall(func(goPath string) error {
_, err := tinygo.EnsureInstalled()
return err
}),
)goinstall.EnsureInstalled(opts ...Option) (string, error) // install if needed, return go binary path
goinstall.Install(opts ...Option) error // force install
goinstall.GetVersion(opts ...Option) (string, error) // e.g. "go version go1.25.2 linux/amd64"
goinstall.IsInstalled(opts ...Option) bool // true if required version is present
goinstall.GetPath(opts ...Option) (string, error) // path to go binarygoinstall.WithVersion("1.25.2") // pin a specific version
goinstall.WithLogger(func(msg string) {...}) // receive progress messages
goinstall.WithAfterInstall(func(goPath string) error {...}) // run after install completes| Platform | Requires | Why |
|---|---|---|
| Linux / macOS | sudo |
Installs to /usr/local |
| Windows | Administrator PowerShell | MSI needs admin rights |
go: command not found after install (Linux/macOS)
hash -r
go versiongo: command not found after install (Windows)
Open a new PowerShell or terminal window.
permission denied on Linux/macOS
curl -fsSL ... | sudo bash # note: sudo goes before bash, not before curlWrong version shown
The shell is using a cached or different Go:
which go # Linux/macOS
where go # Windows