Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/glacials/pottytrainer. a solution to bad poops
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536package server
import ( "embed" "io/fs" "log" "net/http" "os")
//go:embed staticvar static embed.FS
// staticFiles returns a http.FileSystem for the static directory. If useOS is// true the returned filesystem will represent the actual OS filesystem. In// general, this should be used when developing so that changes are reflected// immediately.//// If useOS is false, the returned filesystem will be a virtual filesystem built// from the static directory. In general, this should be used in production so// that we can ship a single binary that includes the static files in it.func staticFiles(useOS bool) http.FileSystem { if useOS { log.Print("using live mode") return http.FS(os.DirFS("static")) }
log.Print("using embed mode") fsys, err := fs.Sub(static, "static") if err != nil { panic(err) }
return http.FS(fsys)}