Skip to content

Instantly share code, notes, and snippets.

@p0lyn0mial
Created July 9, 2020 08:59
Show Gist options
  • Save p0lyn0mial/870b2c281b883fd2e23154dc7505a07a to your computer and use it in GitHub Desktop.
Save p0lyn0mial/870b2c281b883fd2e23154dc7505a07a to your computer and use it in GitHub Desktop.
comparing function pointers in golang
the following is what I got when running https://github.com/p0lyn0mial/function-addr/blob/master/main.go with various versions of golang
==============================================================================================================
go1.13.12
==============================================================================================================
go version && go run main.go
go version go1.13.12 darwin/amd64
a
b
0x109b750
0x109b750
panic: a and b point to the same address!
goroutine 1 [running]:
main.main()
/Users/lszaszki/go/src/github.com/p0lyn0mial/function-addr/main.go:13 +0x4b5
exit status 2
==============================================================================================================
go1.12.1
==============================================================================================================
go version && go run main.go
go version go1.12.1 darwin/amd64
a
b
0x1095160
0x1095160
panic: a and b point to the same address!
goroutine 1 [running]:
main.main()
/Users/lszaszki/go/src/github.com/p0lyn0mial/function-addr/main.go:13 +0x4fa
exit status 2
==============================================================================================================
go1.11.1
==============================================================================================================
go version && go run main.go
go version go1.11.1 darwin/amd64
a
b
0x1093250
0x1093250
panic: a and b point to the same address!
goroutine 1 [running]:
main.main()
/Users/lszaszki/go/src/github.com/p0lyn0mial/function-addr/main.go:13 +0x4cb
exit status 2
==============================================================================================================
go1.10.1
==============================================================================================================
go version && go run main.go
go version go1.10.1 darwin/amd64
a
b
0x108f800
0x108f800
panic: a and b point to the same address!
goroutine 1 [running]:
main.main()
/Users/lszaszki/go/src/github.com/p0lyn0mial/function-addr/main.go:13 +0x4cd
exit status 2
==============================================================================================================
go1.9.1
==============================================================================================================
go version && go run main.go
go version go1.9.1 darwin/amd64
a
b
0x10959b0
0x10959b0
panic: a and b point to the same address!
goroutine 1 [running]:
main.main()
/Users/lszaszki/go/src/github.com/p0lyn0mial/function-addr/main.go:13 +0x58a
exit status 2
==============================================================================================================
go1.8.1
==============================================================================================================
go version && go run main.go
go version go1.8.1 darwin/amd64
a
b
0x1089630
0x1089630
panic: a and b point to the same address!
goroutine 1 [running]:
main.main()
/Users/lszaszki/go/src/github.com/p0lyn0mial/function-addr/main.go:13 +0x512
exit status 2
==============================================================================================================
go1.7.1
=============================================================================================================
go version && go run main.go
go version go1.7.1 darwin/amd64
a
b
0x2600
0x2600
panic: a and b point to the same address!
goroutine 1 [running]:
panic(0x8bc40, 0xc42007a0d0)
/Users/lszaszki/.gimme/versions/go1.7.1.darwin.amd64/src/runtime/panic.go:500 +0x1a1
main.main()
/Users/lszaszki/go/src/github.com/p0lyn0mial/function-addr/main.go:13 +0x509
exit status 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment