Skip to content

Unused build-info vars in internal/cli/root.go #7

@jadb

Description

@jadb

Problem

staticcheck U1000 reports version, commit, date are unused at internal/cli/root.go:31-33.

SetVersion(v,c,d) assigns them and sets RootCmd.Version, but the vars themselves aren't referenced elsewhere.

Fix (recommended)

Remove the stored vars and use RootCmd.Version only:

-  // Build info
-  version string
-  commit  string
-  date    string
 )

 func SetVersion(v, c, d string) {
-  version = v
-  commit = c
-  date = d
   if RootCmd != nil {
     RootCmd.Version = fmt.Sprintf("%s (commit: %s, built: %s)", v, c, d)
   }
 }

Alternative: if the vars are needed later, reference them somewhere (e.g., debug output). But removing them is simplest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions