gofasta upgrade
Checks GitHub for a newer release of the CLI and installs it in place. The upgrade strategy is chosen automatically from where the running binary lives, so the same command works whether you installed with go install or downloaded a pre-built binary.
Usage
gofasta upgradeThe command takes no flags of its own. The root command’s global flags apply, including --json.
What happens
- Check. The latest release tag is read from the GitHub releases API. Leading
vcharacters are stripped from both sides before comparing, sov1.2.3and1.2.3are equal. If the versions match, the command reports that you are up to date and exits without touching anything. - Detect. If the running executable lives under
$GOPATH(or~/gowhenGOPATHis unset), the binary is treated as ago installbuild. Anything else is treated as a pre-built binary. - Install. See the two strategies below.
- Verify. After a
go installupgrade, the newly written binary is executed with--versionand the result is compared against the expected release tag. A mismatch is reported as an error with a hint to check$GOBIN/$GOPATH— it nearly always meansgo installwrote the binary to a different directory than the one on yourPATH.
Pseudo-versions like v0.1.10-0.20260728120000-abc1234 — what you get from go install against a branch — never compare equal to a release tag, so a dev build is always considered upgradeable.
The two strategies
| Detected as | What runs |
|---|---|
go install build | go install github.com/gofastadev/cli/cmd/gofasta@<tag>, pinned to the exact tag rather than @latest. |
| Pre-built binary | Downloads the platform-matched asset from the release, verifies its SHA-256, and replaces the running binary in place. |
The pinned tag matters. The version check queries the GitHub releases API directly, while go install …@latest resolves through the Go module proxy, which has its own indexing lag — for minutes to hours after a tag is pushed the proxy can still report the previous version as latest. Pinning to @v0.1.10 asks for that exact version and sidesteps the race.
For the binary path, the asset is written to a temp file first, and the replacement is an atomic os.Rename over the current executable. If the rename crosses a filesystem boundary it falls back to a read-and-write copy.
Checksum verification
Before the downloaded binary is made executable — and before anything overwrites the binary you are currently running — its SHA-256 is compared against the entry in the checksums.txt asset published with the same release.
Every failure in that path is fatal: a checksums file that cannot be fetched, a missing entry for the asset, or a digest that does not match all abort with the UPGRADE_VERIFICATION_FAILED code. There is no fallback that installs an unverified binary, because a self-updater that skips verification is a supply-chain hole — a compromised mirror or a MITM could swap the asset for anything.
JSON output
$ gofasta upgrade --json
{
"action": "upgrade",
"method": "go-install",
"old_version": "0.1.9",
"new_version": "0.1.10",
"upgraded": true,
"success": true
}| Field | Meaning |
|---|---|
method | go-install, binary, or none (nothing was installed — already current, or the check failed). |
old_version / new_version | Normalized, without the leading v. |
path | Where the new binary was written. Present for the binary strategy and for go install when the target was resolved. |
upgraded | false when already on the latest release. |
success | false when the upgrade failed; error then carries the reason. |
An agent can read method to decide whether follow-up advice about hash -r or a shell restart is warranted.
After upgrading
If gofasta --version still reports the old version in the same terminal, your shell has cached the previous executable’s inode. Refresh it:
hash -r # bash / zsh
rehash # zsh (alternative)Or open a new terminal.
Permissions
The binary strategy writes to wherever the current executable lives. If that is a root-owned directory such as /usr/local/bin — where the install script puts it — the write fails without elevated permissions, and the error says so. Re-run with sudo, or reinstall to a directory you own.
Errors
| Code | When |
|---|---|
UPGRADE_VERIFICATION_FAILED | The download could not be verified against the release checksums. Nothing was installed. |
Network failures, a missing release asset, and a post-install version mismatch are reported as plain errors with the underlying cause attached. See Error codes for the full registry.