Skip to content

Instantly share code, notes, and snippets.

@HauptJ
Created June 12, 2018 05:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HauptJ/58e78219dd3e7a35a15c5c23bf828b9f to your computer and use it in GitHub Desktop.
Save HauptJ/58e78219dd3e7a35a15c5c23bf828b9f to your computer and use it in GitHub Desktop.
Golang function to write a string to a file with overwrite
/*
DESC: writes to new file
IN: output file: outFile, string of contents to write: contents
OUT: nill on success
*/
func write_file(outFile, contents string) error {
err := ioutil.WriteFile(outFile, []byte(contents), 0644)
if err != nil {
panic(err)
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment