Skip to content

Commit

Permalink
fix: do not apply a nil option
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonanCarvalho committed Dec 27, 2022
1 parent a69057a commit 4c00e53
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ type Gen struct {
// GenOption is a function type that can be used to configure a Gen generator.
type GenOption func(*Gen)

var emptyGenOption = func(*Gen) {}

// interface check -- build will fail if *Gen doesn't satisfy Generator
var _ Generator = (*Gen)(nil)

Expand Down Expand Up @@ -177,7 +179,9 @@ func NewGenWithOptions(opts ...GenOption) *Gen {
}

for _, opt := range opts {
opt(gen)
if opt != nil {
opt(gen)
}
}

return gen
Expand Down

0 comments on commit 4c00e53

Please sign in to comment.