Skip to content

Commit

Permalink
wops!
Browse files Browse the repository at this point in the history
  • Loading branch information
MetalBlueberry committed May 25, 2024
1 parent cda0973 commit 14beba4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions types/arrayok.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

func ArrayOKValue[T any](value T) ArrayOK[*T] {
v := &value
return ArrayOK[*T]{Value: &v}
return ArrayOK[*T]{Value: v}
}

func ArrayOKArray[T any](array ...T) ArrayOK[*T] {
Expand All @@ -23,7 +23,7 @@ func ArrayOKArray[T any](array ...T) ArrayOK[*T] {
// ArrayOK is a type that allows you to define a single value or an array of values, But not both.
// If Array is defined, Value will be ignored.
type ArrayOK[T any] struct {
Value *T
Value T
Array []T
}

Expand All @@ -36,7 +36,6 @@ func (arrayOK *ArrayOK[T]) MarshalJSON() ([]byte, error) {

func (arrayOK *ArrayOK[T]) UnmarshalJSON(data []byte) error {
arrayOK.Array = nil
arrayOK.Value = nil

var array []T
err := json.Unmarshal(data, &array)
Expand All @@ -50,6 +49,6 @@ func (arrayOK *ArrayOK[T]) UnmarshalJSON(data []byte) error {
if err != nil {
return err
}
arrayOK.Value = &value
arrayOK.Value = value
return nil
}

0 comments on commit 14beba4

Please sign in to comment.