Create ( filename ) if err!= nil { return err } defer f. Close () _, err = f. Write ( data ) return err } This looks fine on the surface, but it actually has a serious flaw.
O_TRUNC, perm ) if err!= nil { return err } n, err := f. Write ( data ) if err == nil && n < len ( data ) { err = io.