Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "log"
- )
- func main() {
- // Allocate a chunk of memory.
- nPtr := new(int)
- // Assign the value indirectly.
- *nPtr = 2
- // 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