seperared file funcs.
This commit is contained in:
parent
e94125f510
commit
30e6bcac6a
26
file.go
Normal file
26
file.go
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func createFile(fileContents string) {
|
||||||
|
file, err := os.Create("weather.json")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("failed creating file: %s", err)
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
_, err = file.WriteString(fileContents)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("failed writing to file: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func removeFile(file string) {
|
||||||
|
e := os.Remove(file)
|
||||||
|
if e != nil {
|
||||||
|
log.Fatal(e)
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user