MCPcopy Create free account
hub / github.com/codehamr/codehamr / Check

Function Check

internal/update/update.go:56–73  ·  view source on GitHub ↗

Check reports whether the local binary's sha256 differs from the remote asset's recorded hash. ctx propagates a startup Ctrl+C into the HTTP request. Returns false on any failure; see package doc.

(ctx context.Context, execPath string)

Source from the content-addressed store, hash-verified

54 remote, err := fetchHash(ctx, asset)
55 if err != nil || remote == "" {
56 return false
57 }
58 return !strings.EqualFold(local, remote)
59}
60
61// assetName mirrors the name_template in .goreleaser.yaml. Every goos goreleaser
62// builds for must have a case here; a missing one silently locks that
63// platform's users out of auto updates (the Windows regression);
64// TestAssetNameCoversEveryReleasedPlatform pins the contract.
65//
66// Unsupported platforms (freebsd, plan9, linux/386, …) return ok=false so Check
67// short circuits before touching the network.
68func assetName(goos, goarch string) (string, bool) {
69 ext := ""
70 switch goos {
71 case "linux":
72 // keep as is
73 case "darwin":
74 goos = "macos"
75 case "windows":
76 // Manifest row reads `<hash> codehamr-windows-<arch>.exe`; match the

Callers 4

maybeSelfUpdateFunction · 0.92
TestCheckReportsUpToDateFunction · 0.85
TestCheckReportsStaleFunction · 0.85

Calls 3

assetNameFunction · 0.85
hashFileFunction · 0.85
fetchHashFunction · 0.85

Tested by 3

TestCheckReportsUpToDateFunction · 0.68
TestCheckReportsStaleFunction · 0.68