Golang 读取控制台输入

package main

import (
    "bufio"
    "log"
    "os"
)

func main() {
    running := true
    reader := bufio.NewReader(os.Stdin)
    for running {
        data, _, _ := reader.ReadLine()
        command := string(data)
        if command == "stop" {
            running = false
        }
        log.Println("command", command)
    }
}
文档更新时间: 2019-06-07 10:24   作者:月影鹏鹏