Skip to content

Commit

Permalink
fix if statement
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnewhall committed Jul 6, 2024
1 parent aaab42e commit 4015355
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions orbit/copier.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ var ErrNotPtr = errors.New("must provide a pointer to a non-nil value")

// Copy is an easy way to copy one data structure to another.
func Copy(src interface{}, dst interface{}) error {
if s := reflect.TypeOf(src); src == nil || s.Kind() != reflect.Ptr {
if src == nil || reflect.TypeOf(src).Kind() != reflect.Ptr {
return fmt.Errorf("copy source: %w", ErrNotPtr)
} else if d := reflect.TypeOf(dst); dst == nil || d.Kind() != reflect.Ptr {
} else if dst == nil || reflect.TypeOf(dst).Kind() != reflect.Ptr {
return fmt.Errorf("copy destination: %w", ErrNotPtr)
}

var buf bytes.Buffer

if err := json.NewEncoder(&buf).Encode(src); err != nil {
return fmt.Errorf("encoding: %w", err)
}
Expand Down

0 comments on commit 4015355

Please sign in to comment.