first go:embed 1.16 implementation

This commit is contained in:
Florian Schade
2021-04-29 01:25:28 +02:00
parent 7405812ad9
commit 47bd449fac
38 changed files with 153 additions and 3443 deletions
-1
View File
@@ -15,7 +15,6 @@ require (
github.com/spf13/viper v1.7.1
github.com/thejerf/suture/v4 v4.0.0
go.opencensus.io v0.23.0
golang.org/x/net v0.0.0-20210119194325-5f4716e94777
)
replace (
+2 -8
View File
@@ -1,6 +1,7 @@
package assets
import (
"github.com/owncloud/ocis/web"
"net/http"
"os"
"path"
@@ -9,8 +10,6 @@ import (
"github.com/owncloud/ocis/web/pkg/config"
)
//go:generate make -C ../.. embed.yml
// assets gets initialized by New and provides the handler.
type assets struct {
logger log.Logger
@@ -42,12 +41,7 @@ func (a assets) Open(original string) (http.File, error) {
}
}
return FS.OpenFile(
CTX,
original,
os.O_RDONLY,
0644,
)
return web.Assets.Open(original)
}
// New returns a new http filesystem to serve assets.
-9
View File
@@ -1,9 +0,0 @@
package assets
import (
// Fake the import to make the dep tree happy.
_ "golang.org/x/net/context"
// Fake the import to make the dep tree happy.
_ "golang.org/x/net/webdav"
)
File diff suppressed because one or more lines are too long
-23
View File
@@ -1,23 +0,0 @@
---
pkg: "assets"
dest: "."
output: "embed.go"
fmt: true
noprefix: true
compression:
compress: true
custom:
- files:
- "../../assets/"
base: "../../assets/"
prefix: ""
exclude:
- "appinfo/**"
- "LICENSE/**"
- "CHANGELOG.md"
- "README.md"
- "config.json"
...
+23
View File
@@ -0,0 +1,23 @@
package web
import (
"embed"
"io/fs"
"net/http"
)
//go:embed assets/*
//go:embed assets/js/*
var assets embed.FS
// Assets FS
var Assets http.FileSystem
func init() {
embedFS, err := fs.Sub(assets, "assets")
if err != nil {
panic(err)
}
Assets = http.FS(embedFS)
}