github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/gnovm/tests/files/method37.gno (about) 1 package main 2 3 import "fmt" 4 5 type Foo struct { 6 A int 7 } 8 9 func (f Foo) GetValue() int { 10 return f.A 11 } 12 13 func main() { 14 f1 := Foo{A: 1} 15 f1GetValue := f1.GetValue 16 f1.A = 2 17 fmt.Println(f1GetValue()) 18 fmt.Println(f1.A) 19 } 20 21 // Output: 22 // 1 23 // 2