Skip to content

Instantly share code, notes, and snippets.

@juwencheng
Last active January 10, 2017 07:49
Show Gist options
  • Save juwencheng/3d1b6e0d0618ba0bf467a6332d13f757 to your computer and use it in GitHub Desktop.
Save juwencheng/3d1b6e0d0618ba0bf467a6332d13f757 to your computer and use it in GitHub Desktop.
将内容以覆盖的形式写入文件中
package main
import (
"io/ioutil"
"time"
)
func main() {
counter := 0
go func() {
for {
ioutil.WriteFile("./truncate.txt", []byte(fmt.Sprintf("%d", counter)), 0755)
counter++
time.Sleep(3 * time.Second)
}
}()
time.Sleep(500 * time.Second)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment