最近在学校,写论文写不下去,还是看书学学技术,夯实下并发编程这块
func chatting(){ inputReader := bufio.NewReader(os.Stdin) fmt.Println("Please input your name!") input, err := inputReader.ReadString('\n') if err != nil { fmt.Printf("An error occured:%s\n", err) os.Exit(1) } else { name := input[:len(input)-1] fmt.Printf("Hello, %s! what can i do for you!!!!\n", name) } for { input, err = inputReader.ReadString('\n') if err!=nil{ fmt.Printf("An error occurred: %s\n", err) continue } input = input[:len(input)-1] input = strings.ToLower(input) switch input { case "":continue case "nothing", "bye" : fmt.Println("Bye!!!") os.Exit(0) default: fmt.Println("Sorry! I didn't catch you") } } }