8000 ParserOptions comment is misleading · Issue #468 · golang-jwt/jwt · GitHub
[go: up one dir, main page]

Skip to content

ParserOptions comment is misleading #468

@breadnette

Description

@breadnette

When attempting to use the Parser options, developers are confronted with a comment which gives incorrect information:

ParserOption is used to implement functional-style options that modify the behavior of the parser. To add new options, just create a function (ideally beginning with With or Without) that returns an anonymous function that takes a *Parser type as input and manipulates its configuration accordingly.

This comment is probably fine (though seemingly unnecessary) as an internal note for maintainers, but since this is part of the godoc comment, it seems to say that it is possible to create new ParserOptions if desired. This is not the case, since Parser is a struct with exclusively unexported members:

type Parser struct {
	// If populated, only these methods will be considered valid.
	validMethods []string


	// Use JSON Number format in JSON decoder.
	useJSONNumber bool


	// Skip claims validation during token parsing.
	skipClaimsValidation bool


	validator *Validator


	decodeStrict bool


	decodePaddingAllowed bool
}

In my opinion, the blurb:

To add new options, just create a function (ideally beginning with With or Without) that returns an anonymous function that takes a *Parser type as input and manipulates its configuration accordingly.
should be removed from the godoc comment, since this is giving incorrect information to developers who check the API documentation because they want to use the library rather than open a PR against it.

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

      0