Here is one of the possible correct solutions: func WriteFile ( filename string, data [] byte ) ( err error ) { f, err := os.
O_TRUNC, perm ) if err!= nil { return err } n, err := f. Write ( data ) if err == nil && n < len ( data ) { err = io.