package main
import "fmt"
func Normal(s string) string {
fmt.Println(&s)
return s
}
func PointerNormal(s *string) string {
fmt.Println(s)
return *s
}
func PointerPointer(s *string) *string {
fmt.Println(s)
return s
}
func main() {
// Normal
fmt.Println("Normal")
ain := "Hello World"
fmt.Println(&ain)
aout := Normal(ain)
fmt.Println(&aout)
// Pass Pointer and Return Normal
fmt.Println("Pointer In Normal Out")
bin := "Hello World"
fmt.Println(&bin)
bout := PointerNormal(&bin)
fmt.Println(&bout)
// Pass Pointer and Return Pointer
fmt.Println("Pointer In Pointer Out")
cin := "Hello World"
fmt.Println(&cin)
cout := PointerPointer(&cin)
fmt.Println(cout)
}
Normal
0xc000010200
0xc000010220
0xc000010210
Pointer In Normal Out
0xc000010230
0xc000010230
0xc000010240
Pointer In Pointer Out
0xc000010250
0xc000010250
0xc000010250