package u import ( "errors" "log/slog" "os" "path/filepath" ) func FileExist(filename string) bool { if _, err := os.Stat(filename); err == nil { return true } else if errors.Is(err, os.ErrNotExist) { return false } else { slog.Warn("Schrödinger's file: it may or may not exist", "file", filename) // Schrodinger: file may or may not exist. To be extra safe it will // report the file doest not exist return false } } // This is just a slin wraper to make easier to compose path in the template type Pathing string func Root() Pathing { return "/" } func (s Pathing) AddPath(p string) Pathing { return Pathing(filepath.Join(string(s), p)) } func (s Pathing) AddPaths(p []string) Pathing { f := filepath.Join(p...) return Pathing(filepath.Join(string(s), f)) } func (s Pathing) Done() string { return string(s) }