create projects.csv if doesn't exist

Implements: https://todo.sr.ht/~amolith/willow/2
This commit is contained in:
Amolith 2023-09-26 16:13:18 -04:00
parent b11accab0a
commit 7a1459f876
Signed by: Amolith
GPG Key ID: 8AE30347CE28D101
1 changed files with 14 additions and 1 deletions

15
main.go
View File

@ -53,7 +53,20 @@ var (
func main() { func main() {
file, err := os.Open("projects.csv") file, err := os.Open("projects.csv")
if err != nil { if err != nil {
log.Fatalln(err) if os.IsNotExist(err) {
file, err = os.Create("projects.csv")
if err != nil {
log.Fatalln(err)
}
defer file.Close()
_, err = file.WriteString("url,name,forge,running\nhttps://git.sr.ht/~amolith/earl,earl,sourcehut,v0.0.1-rc0\n")
if err != nil {
log.Fatalln(err)
}
} else {
log.Fatalln(err)
}
} }
defer file.Close() defer file.Close()