mirror of
https://github.com/Luzifer/ots.git
synced 2025-08-01 18:56:04 -04:00
Switch to Go 1.16 embed functionality (#42)
commit 8b9ecaaa2fe8b65e3a32317e2979387af39b5262 Author: Vic Demuzere <vic@demuzere.be> Date: Tue Aug 24 15:14:38 2021 +0200 Switch to Go 1.6 embed functionality This means the go-bindata compile-time dependency is no longer needed. closes #42 Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
f1751aff86
commit
71fa3b7590
5 changed files with 10 additions and 63118 deletions
8
main.go
8
main.go
|
@ -1,8 +1,7 @@
|
|||
package main
|
||||
|
||||
//go:generate go-bindata -pkg $GOPACKAGE -o assets.go -modtime 1 -md5checksum ./frontend/...
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"mime"
|
||||
"net/http"
|
||||
|
@ -29,6 +28,9 @@ var (
|
|||
version = "dev"
|
||||
)
|
||||
|
||||
//go:embed frontend/*
|
||||
var assets embed.FS
|
||||
|
||||
func init() {
|
||||
if err := rconfig.ParseAndValidate(&cfg); err != nil {
|
||||
log.Fatalf("Error parsing CLI arguments: %s", err)
|
||||
|
@ -75,7 +77,7 @@ func assetDelivery(res http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
ext := assetName[dot:]
|
||||
assetData, err := Asset(path.Join("frontend", assetName))
|
||||
assetData, err := assets.ReadFile(path.Join("frontend", assetName))
|
||||
if err != nil {
|
||||
http.Error(res, "404 not found", http.StatusNotFound)
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue