Skip to content

Instantly share code, notes, and snippets.

@byronmansfield
Last active January 23, 2016 22:07
Show Gist options
  • Save byronmansfield/0ef3c38e9cb8385350fa to your computer and use it in GitHub Desktop.
Save byronmansfield/0ef3c38e9cb8385350fa to your computer and use it in GitHub Desktop.
Go pointer example
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!"
}
@byronmansfield
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment