mirror of
https://github.com/crazybber/awesome-patterns.git
synced 2024-11-25 22:36:05 +03:00
46 lines
639 B
Go
46 lines
639 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"github.com/davecgh/go-spew/spew"
|
||
|
)
|
||
|
|
||
|
type Person struct {
|
||
|
Name string
|
||
|
Age int
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
|
||
|
s := "TTTT"
|
||
|
ps := &s
|
||
|
spew.Dump("ORIGINAL PS", ps)
|
||
|
spew.Dump("ADDRESS OF PS", &ps)
|
||
|
|
||
|
pass(ps)
|
||
|
spew.Dump("The Value Of S", s)
|
||
|
p1 := &Person{"Jian", 23}
|
||
|
passStruct(p1)
|
||
|
spew.Dump("STRUCT AFTER PASSS STRUCT", p1)
|
||
|
|
||
|
}
|
||
|
|
||
|
func pass(ps *string) {
|
||
|
*ps = "ZZZZZZZZZZZZZZZZZ"
|
||
|
spew.Dump("PS IN PASS FUNCIONT", ps)
|
||
|
spew.Dump("ADDRESS OF PS IN PASS FUNCIONT", &ps)
|
||
|
ps = nil
|
||
|
}
|
||
|
|
||
|
func passStruct(p *Person) {
|
||
|
p.Name = "Steve"
|
||
|
p = nil
|
||
|
}
|
||
|
|
||
|
func passStruct2(p Person) {
|
||
|
p.Name = "Steve"
|
||
|
}
|
||
|
|
||
|
func passVAL(v string) {
|
||
|
v = ""
|
||
|
}
|