📝 Added pointer example
This commit is contained in:
parent
4bfa9492a2
commit
156bf5fef1
|
@ -0,0 +1,22 @@
|
|||
package pointer_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"source.toby3d.me/toby3d/hacks/pointer"
|
||||
)
|
||||
|
||||
func Example() {
|
||||
val := struct {
|
||||
Text string
|
||||
}{Text: "Hello, World!"}
|
||||
fmt.Printf("Value: %v\n", val)
|
||||
|
||||
point := pointer.Of(val)
|
||||
point.Text = "Hello, Go!"
|
||||
fmt.Printf("Pointer: %v\n", point)
|
||||
|
||||
// Output:
|
||||
// Value: {Hello, World!}
|
||||
// Pointer: &{Hello, Go!}
|
||||
}
|
Loading…
Reference in New Issue