1
Fork 0
mirror of https://github.com/RGBCube/GoNew synced 2025-07-30 17:07:45 +00:00

Rename package to ptr

This commit is contained in:
RGBCube 2023-04-10 22:39:29 +03:00
parent 9dc7cb7b36
commit 717ed11ee0
2 changed files with 3 additions and 3 deletions

View file

@ -17,14 +17,14 @@ func String(ok bool) *string {
// s := "Hello, World!" // s := "Hello, World!"
// return &s // return &s
// You now can do this! // You now can do this!
return new.New("Hello, World!") return ptr.New("Hello, World!")
} }
return nil return nil
} }
func Int32(ok bool) *int32 { func Int32(ok bool) *int32 {
if ok { if ok {
return new.New[int32](42) return ptr.New[int32](42)
} }
return nil return nil
} }

2
new.go
View file

@ -1,4 +1,4 @@
package new package ptr
// New allocates the thing on the heap and returns a non-nil pointer to it. // New allocates the thing on the heap and returns a non-nil pointer to it.
func New[T any](thing T) *T { func New[T any](thing T) *T {