vim saved "./a.log" file when golang writing file. After that the golang program can't write file. There are no error messages and no hang. run for looping is very well except saved file.
Is there any solution?
import (
"fmt"
"io"
"os"
"time"
)
func main() {
var f1 *os.File
f1, _ = os.OpenFile("./a.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
iCnt := 0
format := ""
for {
iCnt++
format = fmt.Sprintf("aaaaaaaaaaa[%d]\r\n", iCnt)
n, err := io.WriteString(f1, format)
if err != nil {
panic(err)
}
f1.Sync()
fmt.Printf("Writed %d bytes\n", n)
fmt.Printf("%v\n", f1)
time.Sleep(3 * time.Second)
}
}
Terminal1) run binary file and see the log file