goharbor / goharbor/harbor-cli

style: align error message formatting with idiomatic Go guidelines

Open
#975 1 comment 0 reactions 0 assignees View on GitHub
enhancement status/has-approved-pr
Dominant language
Go
Stars
163
Forks
211
Avg merge
1m
Merged PRs (30d)
1

Description

Overview
Standardize error message formatting across the codebase to adhere to the official Go style guidelines. Currently, multiple files in both the command layer (cmd/harbor/root/...) and the support packages (pkg/...) return error strings that start with uppercase letters (e.g., Failed to..., URL must...).

Rationale
According to the [Go Code Review Comments](https://github.com/golang/go/wiki/CodeReviewComments#error-strings):

"Error strings should not be capitalized (unless beginning with proper nouns or acronyms) or end with punctuation, since they are usually printed following other context."

Standardizing these error messages ensures that when errors are wrapped or printed in the CLI, they flow naturally and maintain a consistent style across the entire application.

Proposed Changes
Modify error message strings in fmt.Errorf and errors.New calls to start with a lowercase letter.

Impacted Areas:

Command Layer (cmd/harbor/root/): Adjust error strings in subcommands under artifact, project, robot, user, registry, tag, and instance.
API & Helper Utilities (pkg/api/, pkg/utils/): Format validation and handler error strings.
UI/Views (pkg/views/): Align view helper and prompt errors.
Verification Plan
Verify that the CLI continues to compile and run successfully (go build).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.