Last active
January 23, 2016 22:07
-
-
Save byronmansfield/0ef3c38e9cb8385350fa to your computer and use it in GitHub Desktop.
Go pointer example
This file contains hidden or 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 | |
func main() { | |
msg := "Hello from Golang" | |
greet(msg) | |
println(msg) | |
greetPrt(&msg) | |
println(msg) | |
} | |
func greet(m string) { | |
println(m) | |
} | |
func greetPrt(m *string) { | |
println("should be pointer address: ", m) | |
println("should be actual string: ", *m) | |
*m = "Hello from Go!" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://play.golang.org/p/k3VmamhKG3