When to flush a file in Go?

前端 未结 4 1034
离开以前
离开以前 2021-02-07 06:35

When is it necessary to flush a file?
I never do it because I call File.Close and I think that it is flushed automatically, isn\'t it?

4条回答
  •  春和景丽
    2021-02-07 07:36

    Looks the most recommendations here are to not to call fsync(), but in general it mainly depends on your application requirement. If you are working on critical file read/write, its always recommended to call fsync().

    http://www.microhowto.info/howto/atomically_rewrite_the_content_of_a_file.html#idp31936

    link, has more details on when file.Sync() will help.

提交回复
热议问题