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 155 views
1 answer 209 views
1 answer 186 views
1 answer 151 views
1 answer 100 views
1 answer 101 views
1 answer 112 views
...