package main import ( "fmt" "os" "bufio" "io" "time" ) func main() { file, err := os.Open("test.txt") defer file.Close() if nil == err { buff := bufio.NewReader(file) for { line, err := buff.ReadString('\n') if err == io.EOF { break } fmt.Print(line) time.Sleep(10*time.Millisecond) } } }
转载于:https://www.cnblogs.com/sherlock-merlin/p/10175212.html