Skip to content

Commit

Permalink
SetValue on nil receiver create a new instance
Browse files Browse the repository at this point in the history
  • Loading branch information
pivaldi committed Apr 25, 2024
1 parent 0bec4f0 commit e06c92d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion of.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ func (n *Of[T]) GetValue() *T {
// SetValue implements the setter.
func (n *Of[T]) SetValue(b T) {
if n == nil {
panic("calling SetValue on nil receiver")
n = new(Of[T])
n.SetValue(b)

return
}

n.Val = &b
Expand Down

0 comments on commit e06c92d

Please sign in to comment.