The flags.LatestFlag() function currently always returns nil for errors, even when operations fail (network errors, JSON parsing errors, etc.). This means:
- The CLI always exits with code
0 (success), even on failure
- Callers have no way to distinguish between success and failure
- Error messages are printed, but the program reports success
Solution
Refactor flags.LatestRelease() to return errors properly:
- Change function signature:
func latestRelease(output *strings.Builder) error
- Return actual errors for all failure cases (URL parsing, HTTP requests, JSON unmarshaling, etc.)
- Update
flags.LatestFlag() to propagate the error: return result, err
- Update CLI to exit with code
1 when error occurs
The
flags.LatestFlag()function currently always returnsnilfor errors, even when operations fail (network errors, JSON parsing errors, etc.). This means:0(success), even on failureSolution
Refactor
flags.LatestRelease()to return errors properly:func latestRelease(output *strings.Builder) errorflags.LatestFlag()to propagate the error:return result, err1when error occurs