From ab1f233bd1713afe388863b42b2ed662debac67a Mon Sep 17 00:00:00 2001 From: Jacob Brewer Date: Wed, 9 Oct 2024 18:21:04 +0100 Subject: [PATCH] feat(utils): Moving utils to a new utils file (#26) Moving utils to a new utils file --- loader.go | 9 --------- pointer.go | 6 ------ utils.go | 17 +++++++++++++++++ 3 files changed, 17 insertions(+), 15 deletions(-) delete mode 100644 pointer.go create mode 100644 utils.go diff --git a/loader.go b/loader.go index 5c21256..dea632e 100644 --- a/loader.go +++ b/loader.go @@ -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 -} diff --git a/pointer.go b/pointer.go deleted file mode 100644 index 9323588..0000000 --- a/pointer.go +++ /dev/null @@ -1,6 +0,0 @@ -package patcher - -// ptr returns a pointer to the value passed in. -func ptr[T any](v T) *T { - return &v -} diff --git a/utils.go b/utils.go new file mode 100644 index 0000000..3814c8c --- /dev/null +++ b/utils.go @@ -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 +}