// Dup1 prints the text of each line that appears more than // once in the standard input, preceded by its count. package main import "fmt" func main() { //这里是 代码包 共享变量的测试 // dup1 //fmt.Printf("dup1:\n") //Dup1() //dup2 //fmt.Printf("dup2:\n") //DUP2() //fmt.Printf("dup3:\n") //DUP3() counts := make(map[string]int) fatherCounts := make(map[string]map[string]int) counts["A"] = 1 counts["B"] = 2 fatherCounts["A"] = counts fmt.Printf("%d\n",counts["A"]) delete(fatherCounts["A"],"A") fmt.Printf("A:%d,B:%d,C:%d\n", fatherCounts["A"]["A"],fatherCounts["A"]["B"],fatherCounts["A"]["C"]) //默认值会赋0 for key := range fatherCounts { fmt.Printf("key:%s",key) } }