Skip to content

Instantly share code, notes, and snippets.

@pm-kartik-sura
Created June 11, 2015 08:15
Show Gist options
  • Select an option

  • Save pm-kartik-sura/5ebbd1f826eb0892d3db to your computer and use it in GitHub Desktop.

Select an option

Save pm-kartik-sura/5ebbd1f826eb0892d3db to your computer and use it in GitHub Desktop.
write string to a file
package main
import (
"fmt"
"io"
"os"
)
func main() {
filename := "test.txt"
fmt.Println("writing: " + filename)
f, err := os.Create(filename)
if err != nil {
fmt.Println(err)
}
n, err := io.WriteString(f, "blahblahblah")
n, err = io.WriteString(f, "blahblahblah")
if err != nil {
fmt.Println(n, err)
}
f.Close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment