Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Panic if AddFlags does not have a pointer receiver #38

@kzantow

Description

@kzantow

If a user defines an AddFlags method which does not have a pointer receiver, it will not properly bind the flag to the value on the object but rather an ephemeral memory location. It also is simply not being called at the moment. An example of this causing a problem in syft where the --key flag was not bound can be seen here. Realistically, this is always a coding problem that needs to be fixed and we should panic if we find AddFlags methods that were incorrectly specified so a user can more quickly get these fixed; i.e. panic if methods seen like this:

func (o Attest) AddFlags(flags fangs.FlagSet) {
	...
}

... instead of this:

func (o *Attest) AddFlags(flags fangs.FlagSet) {
	...
}

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