[Golang]OS系统调用浅析

erlib ·
The golang version ``` package main import ( "bytes" "flag" "fmt" "strings" ) func main() { //take input from flag str := flag.String("str", "", "input a string") flag.Parse() if len(*str) == 0 { flag.PrintDefaults() return } replacer := strings.NewReplacer("'", "", " ", "") *str = replacer.Replace(*str) counter := make(map[rune]int) //count individual character for _, ch := range bytes.Runes([]byte(*str)) { counter[ch]++ } //print out the result for k, v := range counter { fmt.Print(string(k)) fmt.Println(" ", v) } } ```
#1