Skip to content

Instantly share code, notes, and snippets.

@thedevsaddam
Forked from pagoenka/appendWrite.go
Created January 16, 2017 05:19
Show Gist options
  • Save thedevsaddam/e84464b1f30117439b812399662a25f7 to your computer and use it in GitHub Desktop.
Save thedevsaddam/e84464b1f30117439b812399662a25f7 to your computer and use it in GitHub Desktop.
Append to file in Go lang
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
fileHandle, _ := os.OpenFile("output.txt", os.O_APPEND, 0666)
writer := bufio.NewWriter(fileHandle)
defer fileHandle.Close()
fmt.Fprintln(writer, "String I want to append")
writer.Flush()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment