1
0
Fork 0

📝 Added pointer example

This commit is contained in:
Maxim Lebedev 2024-03-18 17:21:27 +05:00
parent 4bfa9492a2
commit 156bf5fef1
Signed by: toby3d
GPG Key ID: 1F14E25B7C119FC5
1 changed files with 22 additions and 0 deletions

22
pointer/pointer_test.go Normal file
View File

@ -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!}
}