Created
May 23, 2010 02:18
-
-
Save EmielM/410574 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ("log") | |
type Test struct { | |
v int | |
} | |
func (t *Test) SetTo(i int) *Test { | |
t.v = i | |
return t | |
} | |
func (t *Test) GetVal() int { | |
return t.v | |
} | |
func main() { | |
s := &Test{0} | |
s.SetTo(1).SetTo(s.GetVal()) | |
log.Stdoutf(".v = %d", s.v) | |
// expected: 1 | |
// darwin/386 8g: 0 | |
// darwin/amd64 6g: 0 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 6g test-chain.go; 6l test-chain.6 | |
$ ./6.out | |
2010/05/24 00:43:17 .v = 0 | |
$ 8g test-chain.go; 8l test-chain.8 | |
$ ./8.out | |
2010/05/24 00:44:20 .v = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0020 (test-chain.go:20) MOVQ AX,s+-48(SP) | |
0021 (test-chain.go:20) MOVQ AX,(SP) | |
0022 (test-chain.go:20) CALL ,*Test·GetVal+0(SB) | |
0023 (test-chain.go:20) MOVL 8(SP),BX | |
0024 (test-chain.go:20) MOVL BX,autotmp_0001+-12(SP) | |
0025 (test-chain.go:20) MOVL $1,8(SP) | |
0026 (test-chain.go:20) MOVQ s+-48(SP),BX | |
0027 (test-chain.go:20) MOVQ BX,(SP) | |
0028 (test-chain.go:20) CALL ,*Test·SetTo+0(SB) | |
0029 (test-chain.go:20) MOVQ 16(SP),BX | |
0030 (test-chain.go:20) MOVQ BX,(SP) | |
0031 (test-chain.go:20) MOVL autotmp_0001+-12(SP),BX | |
0032 (test-chain.go:20) MOVL BX,8(SP) | |
0033 (test-chain.go:20) CALL ,*Test·SetTo+0(SB) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment