Skip to content

Instantly share code, notes, and snippets.

@SoMuchForSubtlety
Last active June 9, 2019 00:23
Show Gist options
  • Select an option

  • Save SoMuchForSubtlety/b77bd3efa180b916b5be4a88fb7f51f6 to your computer and use it in GitHub Desktop.

Select an option

Save SoMuchForSubtlety/b77bd3efa180b916b5be4a88fb7f51f6 to your computer and use it in GitHub Desktop.
simple program to write a string to a file
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