Skip to content

Conversation

dsnet
Copy link
Collaborator

@dsnet dsnet commented Dec 16, 2019

Add an Exporter option that accepts a function to determine
which struct types to permit access to unexported fields.
Treat this as a first-class option and implement AllowUnexported
in terms of the new Exporter option.

The new Exporter option:

  • Better matches the existing style of top-level options
    both by name (e.g., Comparer, Transformer, and Reporter)
    and by API style (all accept a function).
  • Is more flexible as it enables users to functionally
    implement AllowAllUnexported by simply doing:
    Exporter(func(reflect.Type) bool { return true })

Fixes #40

Add an Exporter option that accepts a function to determine
which struct types to permit access to unexported fields.
Treat this as a first-class option and implement AllowUnexported
in terms of the new Exporter option.

The new Exporter option:
* Better matches the existing style of top-level options
both by name (e.g., Comparer, Transformer, and Reporter)
and by API style (all accept a function).
* Is more flexible as it enables users to functionally
implement AllowAllUnexported by simply doing:
	Exporter(func(reflect.Type) bool { return true })
@dsnet dsnet merged commit e1f03df into master Dec 16, 2019
@dsnet dsnet deleted the exporter branch December 16, 2019 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement an AllowAllUnexported Option
2 participants