Skip to content

Commit

Permalink
Remove panic
Browse files Browse the repository at this point in the history
  • Loading branch information
pivaldi committed Mar 28, 2024
1 parent e8fd36f commit e6d831f
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions of.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ 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.Val = &b
}

Expand All @@ -56,7 +52,7 @@ func (n *Of[T]) SetValueP(ref *T) {
// SetNull set to null.
func (n *Of[T]) SetNull() {
if n == nil {
panic("calling SetNull on nil receiver")
return
}

n.Val = nil
Expand All @@ -76,7 +72,7 @@ func (n *Of[T]) MarshalJSON() ([]byte, error) {
// UnmarshalJSON implements the decoding json interface.
func (n *Of[T]) UnmarshalJSON(data []byte) error {
if n == nil {
panic("calling UnmarshalJSON on nil receiver")
return nil
}

if n.Val == nil && data != nil {
Expand Down

0 comments on commit e6d831f

Please sign in to comment.