Last active
June 9, 2019 00:23
-
-
Save SoMuchForSubtlety/b77bd3efa180b916b5be4a88fb7f51f6 to your computer and use it in GitHub Desktop.
simple program to write a string to a file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "flag" | |
| "fmt" | |
| "os" | |
| ) | |
| var ( | |
| content = flag.String("content", "", "what gets written to the file") | |
| dir = flag.String("dir", "./downloads/stream.strm", "the file you want to write to") | |
| ) | |
| func main() { | |
| flag.Parse() | |
| f, err := os.Create(*dir) | |
| if err != nil { | |
| fmt.Println(err) | |
| return | |
| } | |
| _, err = f.WriteString(*content) | |
| if err != nil { | |
| fmt.Println(err) | |
| f.Close() | |
| return | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment