Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Deref ¶
func Deref[T any](v *T) T
Deref will return the referenced value, or if the pointer has no value, then it returns with the zero value.
Example ¶
package main import ( "go.llib.dev/frameless/pkg/pointer" ) type ExampleStruct struct { StrPtrField *string IntPtrField *int } func main() { var es ExampleStruct _ = pointer.Deref(es.StrPtrField) _ = pointer.Deref(es.IntPtrField) }
func Link ¶ added in v0.194.0
Example ¶
package main import ( "go.llib.dev/frameless/pkg/pointer" ) func main() { var ( src string = "Hello, world!" dst string ) if err := pointer.Link(src, &dst); err != nil { panic(err) } }
Example (UsingInUnmarshal) ¶
package main import ( "go.llib.dev/frameless/pkg/pointer" ) func main() { var unmarshalFunc = func(data []byte, ptr any) error { var out string out = string(data) // process data return pointer.Link(out, ptr) } var val string if err := unmarshalFunc([]byte("data"), &val); err != nil { panic(err) } // val == "data" }
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.