mirror of
https://github.com/onyx-and-iris/gignore.git
synced 2025-04-01 19:23:51 +01:00
open file in append mode
This commit is contained in:
parent
a3c2d2cfbf
commit
388a204299
@ -29,14 +29,14 @@ func (fw *FileWriter) writeContent(content []byte, dst io.Writer) (int64, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (fw *FileWriter) Write(content []byte) (int, error) {
|
func (fw *FileWriter) Write(content []byte) (int, error) {
|
||||||
f, err := os.Create(fw.targetFileName)
|
f, err := os.OpenFile(fw.targetFileName, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
const header = `# Auto-generated .gitignore by gignore: github.com/onyx-and-iris/gignore`
|
const header = "# Auto-generated .gitignore by gignore: github.com/onyx-and-iris/gignore\n"
|
||||||
const footer = `# End of gignore: github.com/onyx-and-iris/gignore`
|
const footer = "\n# End of gignore: github.com/onyx-and-iris/gignore\n"
|
||||||
|
|
||||||
var sz int64
|
var sz int64
|
||||||
n, err := fw.writeContent([]byte(header), f)
|
n, err := fw.writeContent([]byte(header), f)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user