tpagectl: VersionPrinter set as global side effect in newCommand #536
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thwap/thwap-pagesd#536
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
cmd/tpagectl/main.gosets the package-globalcli.VersionPrinteras a side effect of thenewCommand()constructor. This is global mutable state: any later command built in the same process (future subcommand trees, parallel tests witht.Parallel()) could have its version output clobbered or race the printer assignment.Context: PR #535 (
cmd/tpagectl/main.go:32).Suggested fix: set
cli.VersionPrinteronce inmain()(beforenewCommand().Run(...)), keeping the constructor free of global side effects. Tests can then call the printer explicitly if needed.Fixed in #634: the global
cli.VersionPrinterassignment is now guarded byversionPrinterSetsonewCommand()has no global side effects.