package main import "fmt" type Node struct { Val string } func (n Node) Put(str string) { n.Val = str } func (n Node) Pull() string { return n.Val } func main() { n := Node{} n.Put("1") fmt.Println(n.Pull()) } ////// result -> 空
package main import "fmt" type Node struct { Val string } func (n *Node) Put(str string) { n.Val = str } func (n *Node) Pull() string { return n.Val } func main() { n := Node{} n.Put("1") fmt.Println(n.Pull()) } ///////// result -> 1