タグ

関連タグで絞り込む (1)

タグの絞り込みを解除

filesystemとgolangに関するa2ikmのブックマーク (1)

  • Don't defer Close() on writable files

    Update: Another approach suggested by the inimitable Ben Johnson has been added to the end of the post. Update 2: Discussion about fsync() added to the end of the post. It’s an idiom that quickly becomes rote to Go programmers: whenever you conjure up a value that implements the io.Closer interface, after checking for errors you immediately defer its Close() method. You see this most often when ma

    a2ikm
    a2ikm 2017/06/25
    Closeで残りのバッファが書き込まれたときにエラーが出てもdeferしてたら返り値に気づけない。deferと明示的なCloseの二段構えにするといい
  • 1