Skip to content

Commit

Permalink
feat(utils): Moving utils to a new utils file (#26)
Browse files Browse the repository at this point in the history
Moving utils to a new utils file
  • Loading branch information
Jacobbrewer1 authored Oct 9, 2024
1 parent 1cb0184 commit ab1f233
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
9 changes: 0 additions & 9 deletions loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,3 @@ func loadDiff[T any](old T, newT T) error {

return nil
}

func isPointerToStruct[T any](t T) bool {
rv := reflect.ValueOf(t)
if rv.Kind() != reflect.Ptr || rv.IsNil() {
return false
}

return rv.Elem().Kind() == reflect.Struct
}
6 changes: 0 additions & 6 deletions pointer.go

This file was deleted.

17 changes: 17 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package patcher

import "reflect"

// ptr returns a pointer to the value passed in.
func ptr[T any](v T) *T {
return &v
}

func isPointerToStruct[T any](t T) bool {
rv := reflect.ValueOf(t)
if rv.Kind() != reflect.Ptr || rv.IsNil() {
return false
}

return rv.Elem().Kind() == reflect.Struct
}

0 comments on commit ab1f233

Please sign in to comment.