Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active February 3, 2026 20:19
Show Gist options
  • Select an option

  • Save dacr/63204c85b62ab4abf95b01bf208fc89b to your computer and use it in GitHub Desktop.

Select an option

Save dacr/63204c85b62ab4abf95b01bf208fc89b to your computer and use it in GitHub Desktop.
go pointers / published by https://github.com/dacr/code-examples-manager #c4cdd92d-c11b-4e88-8090-2b2d00926bd0/7d0ffc6cd431081fc986e662060ba6c854356712
/*?sr/bin/true; exec /usr/bin/env nix-shell -p go --run "go run $0" #*/
// summary : go pointers
// keywords : go, pointers, @testable
// publish : gist
// authors : David Crosson
// license : Apache License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt)
// id : c4cdd92d-c11b-4e88-8090-2b2d00926bd0
// created-on : 2025-03-27T11:01:31+01:00
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : nix-shell -p go --run "go run $file"
package main
import "fmt"
func main() {
var ptr *string // nil by default
//*ptr = "crash" !
value := "blabla"
ptr = &value
fmt.Println(*ptr)
value2 := *ptr
*ptr = "bouhhh!!!!!!!!!!!!!!!!!"
fmt.Println(value)
fmt.Println(value2)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment