Last active
November 30, 2021 21:32
-
-
Save ercang/18b4d5c0ff86496a726c2e9ca8abda07 to your computer and use it in GitHub Desktop.
Simple pointer escape example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
var pointerToInt *int = ReturnStackVariable() | |
fmt.Printf("Here is the number! %v\n", *pointerToInt) | |
} | |
func ReturnStackVariable() *int { | |
localVariable := 10 | |
return &localVariable | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In order to see the output of the pointer escape example, please compile with the following option.