标签:strong cli hid cep main 使用 str 设置 stopped
// 实现枚举例子 type State int // iota 初始化后会自动递增 const ( Running State = iota // value --> 0 Stopped // value --> 1 Rebooting // value --> 2 Terminated // value --> 3 ) func (this State) String() string { switch this { case Running: return "Running" case Stopped: return "Stopped" default: return "Unknow" } } func main() { state := Stopped fmt.Println("state", state) } // 输出 state Running // 没有重载String函数的情况下则输出 state 0
package main import "fmt" func testSliceParams(strs []string, msg string) { fmt.Printf("WangAo test: strs----2: %d %d %p %v\n", len(strs), cap(strs), &strs, strs) tmp := strs[0] strs[0] = msg fmt.Printf("WangAo test: strs----3: %d %d %p %v\n", len(strs), cap(strs), &strs, strs) strs = append(strs, msg) fmt.Printf("WangAo test: strs----4: %d %d %p %v\n", len(strs), cap(strs), &strs, strs) strs[0] = tmp fmt.Printf("WangAo test: strs----5: %d %d %p %v\n", len(strs), cap(strs), &strs, strs) strs = append(strs, msg) fmt.Printf("WangAo test: strs----6: %d %d %p %v\n", len(strs), cap(strs), &strs, strs) strs = append(strs, msg) fmt.Printf("WangAo test: strs----7: %d %d %p %v\n", len(strs), cap(strs), &strs, strs) strs = append(strs, msg) fmt.Printf("WangAo test: strs----8: %d %d %p %v\n", len(strs), cap(strs), &strs, strs) strs = append(strs, msg) fmt.Printf("WangAo test: strs----9: %d %d %p %v\n", len(strs), cap(strs), &strs, strs) tmp = strs[0] strs[0] = msg fmt.Printf("WangAo test: strs---10: %d %d %p %v\n", len(strs), cap(strs), &strs, strs) } func main() { strs := make([]string, 0, 3) strs = append(strs, "test1") fmt.Printf("WangAo test: strs----1: %d %d %p %v\n", len(strs), cap(strs), &strs, strs) testSliceParams(strs, "test2") fmt.Printf("WangAo test: strs---11: %d %d %p %v\n", len(strs), cap(strs), &strs, strs) }
标签:strong cli hid cep main 使用 str 设置 stopped
原文地址:https://www.cnblogs.com/wangao1236/p/10898950.html