How to get the address of a variable in Go

1 Answer

0 votes
package main

import (
	"fmt"
)

func main() {
	pi := 3.14
	ptr := &pi
	
	fmt.Println("Address:", ptr, &pi)
	fmt.Printf("Address: %p %p\n", ptr, &pi)
}




/*
run:

Address: 0xc000014080 0xc000014080
Address: 0xc000014080 0xc000014080

*/

 



answered Nov 4, 2022 by avibootz

Related questions

1 answer 160 views
1 answer 213 views
1 answer 197 views
1 answer 164 views
1 answer 116 views
1 answer 105 views
1 answer 120 views
...