Skip to content

Instantly share code, notes, and snippets.

@pressure679
Last active August 29, 2015 14:16
Show Gist options
  • Save pressure679/a98abac3359ac604d48d to your computer and use it in GitHub Desktop.
Save pressure679/a98abac3359ac604d48d to your computer and use it in GitHub Desktop.
func writefile(filename, txt string) {
f, err := os.OpenFile(filename, os.O_APPEND, 0644)
checkerr(err)
_, err = f.WriteString("\n" + "go" + txt)
checkerr(err)
f.Close()
}
@flexd
Copy link

flexd commented Mar 9, 2015

I'm not sure exactly what you wanted since you left IRC so quick, but my impression was that you wanted to append to one file and write to another new file.

You could accomplish this by using a io.MultiWriter http://golang.org/pkg/io/#MultiWriter

Just give it two or more different writers and it will duplicate whatever you write to it to all writers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment