Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Data map[string]any to store arbitrary command data #2085

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
// command does not define one.
Version string

// Data are key/value pairs of arbitrary types that can be used by applications or "plugin" libraries
// that wish to store and use data associated with a given command. This data will thus share the same
// lifetime as the command itself.
Data map[string]any

Check failure on line 117 in command.go

View workflow job for this annotation

GitHub Actions / ubuntu | 1.17.x

undefined: any

Check failure on line 117 in command.go

View workflow job for this annotation

GitHub Actions / macOS | 1.17.x

undefined: any
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any was introduced in go 1.18.
Cobra still supports go 1.15. I know these are very old versions, but I am the opinion that if we don't need to drop support, why do it.

So, can we change any to interface{}?


// The *Run functions are executed in the following order:
// * PersistentPreRun()
// * PreRun()
Expand Down
Loading