package model import ( "log" "os" "path/filepath" ) type Storage struct { Path string } func (s Storage) Exists() bool { _, err := os.Stat(s.Path) return !os.IsNotExist(err) } func (s Storage) Create() { err := os.Mkdir(s.Path, 0750) if err != nil { log.Fatal(err) } } func (s *Storage) Init(version string) { if version != "" { vp := filepath.Join(s.Path, "version.txt") err := os.WriteFile(vp, []byte(version+"\n"), 0644) if err != nil { log.Fatal(err) } } log.Printf("Storage directory: %s\n", s.Path) }