创建文件MMFeel.go
package memento
import "fmt"
type MMFeel struct {
    Tall     int
    Rich     int
    Handsome int
}
var States []MMFeel = make([]MMFeel, 0)
var StatesLength int = 0 // 记录轨迹
func (mmf *MMFeel) FirstMeet(tall, rich, handsome int) {
    mmf.Tall = tall
    mmf.Rich = rich
    mmf.Handsome = handsome
    States = append(States, *mmf)
}
func (mmf *MMFeel) GoKorea() {
    mmf.Handsome += 30
    States = append(States, *mmf)
}
func (mmf *MMFeel) WinLottery() {
    mmf.Rich += 5000000
    States = append(States, *mmf)
}
func (mmf *MMFeel) Short() {
    mmf.Tall += 10
    States = append(States, *mmf)
}
func (mmf *MMFeel) Score() {
    fmt.Println("当前状态", mmf.Tall, mmf.Rich, mmf.Handsome)
}
main.go
package main
import (
    "fmt"
    "ssp_api_go/test/design/memento"
)
func main() {
    var xxl *memento.MMFeel = &memento.MMFeel{0, 0, 0}
    xxl.FirstMeet(170, 500000, 70)
    xxl.WinLottery()
    xxl.GoKorea()
    xxl.Short()
    xxl.Score()
    fmt.Println(memento.States)
}