You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-weather/file.go

28 lines
443 B

package main
import (
"log"
"os"
)
2 years ago
func createFile(fileContents string, filename string) {
file, err := os.Create(filename)
if err != nil {
2 years ago
log.Fatalf("failed creating file %s: %s", filename, err)
}
defer file.Close()
_, err = file.WriteString(fileContents)
if err != nil {
2 years ago
log.Fatalf("failed writing to file %s: %s", filename, err)
}
}
func removeFile(file string) {
e := os.Remove(file)
if e != nil {
log.Fatal(e)
}
}