Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "log"
- )
- func main() {
- n := 2
- // Reference the adress from the variable.
- nPtr := &n
- // Print out the address.
- fmt.Println(nPtr)
- // Dereference the pointer to get the value.
- if !(*nPtr == 2) {
- log.Fatal("Wrong value")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement