Upgrade to go 1.16 and use embed module

This commit is contained in:
nemunaire 2022-09-02 17:09:13 +02:00
commit 6564d9c4fa
28 changed files with 71 additions and 3099 deletions

32
assets-dev.go Normal file
View file

@ -0,0 +1,32 @@
//go:build dev
// +build dev
package main
import (
"flag"
"net/http"
"os"
"path/filepath"
)
var (
Assets http.FileSystem
StaticDir string = "static/"
)
func init() {
flag.StringVar(&StaticDir, "static", StaticDir, "Directory containing static files")
}
func sanitizeStaticOptions() error {
StaticDir, _ = filepath.Abs(StaticDir)
if _, err := os.Stat(StaticDir); os.IsNotExist(err) {
StaticDir, _ = filepath.Abs(filepath.Join(filepath.Dir(os.Args[0]), "static"))
if _, err := os.Stat(StaticDir); os.IsNotExist(err) {
return err
}
}
Assets = http.Dir(StaticDir)
return nil
}