create projects.csv if doesn't exist
Implements: https://todo.sr.ht/~amolith/willow/2
This commit is contained in:
parent
b11accab0a
commit
7a1459f876
13
main.go
13
main.go
|
@ -52,11 +52,24 @@ var (
|
|||
|
||||
func main() {
|
||||
file, err := os.Open("projects.csv")
|
||||
if err != nil {
|
||||
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()
|
||||
|
||||
reader := csv.NewReader(file)
|
||||
|
||||
records, err := reader.ReadAll()
|
||||
|
|
Loading…
Reference in New Issue