Skip to content

Instantly share code, notes, and snippets.

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