Build : using go:generate and go:embed (#2195)

* using go:generate and go:embed

* fix import
This commit is contained in:
Ali Kefia
2021-08-25 04:02:29 +02:00
committed by GitHub
parent fe3186ba9d
commit ec3292e8c4
8 changed files with 47 additions and 7717 deletions

View File

@@ -9,6 +9,8 @@ import (
"path/filepath"
"regexp"
"strings"
rt "github.com/zyedidia/micro/v2/runtime"
)
const (
@@ -90,7 +92,7 @@ func (af assetFile) Name() string {
}
func (af assetFile) Data() ([]byte, error) {
return Asset(string(af))
return rt.Asset(string(af))
}
func (nf namedFile) Name() string {
@@ -123,7 +125,7 @@ func AddRuntimeFilesFromDirectory(fileType RTFiletype, directory, pattern string
// AddRuntimeFilesFromAssets registers each file from the given asset-directory for
// the filetype which matches the file-pattern
func AddRuntimeFilesFromAssets(fileType RTFiletype, directory, pattern string) {
files, err := AssetDir(directory)
files, err := rt.AssetDir(directory)
if err != nil {
return
}
@@ -214,9 +216,9 @@ func InitRuntimeFiles() {
}
plugdir = filepath.Join("runtime", "plugins")
if files, err := AssetDir(plugdir); err == nil {
if files, err := rt.AssetDir(plugdir); err == nil {
for _, d := range files {
if srcs, err := AssetDir(filepath.Join(plugdir, d)); err == nil {
if srcs, err := rt.AssetDir(filepath.Join(plugdir, d)); err == nil {
p := new(Plugin)
p.Name = d
p.DirName = d
@@ -225,7 +227,7 @@ func InitRuntimeFiles() {
if strings.HasSuffix(f, ".lua") {
p.Srcs = append(p.Srcs, assetFile(filepath.Join(plugdir, d, f)))
} else if strings.HasSuffix(f, ".json") {
data, err := Asset(filepath.Join(plugdir, d, f))
data, err := rt.Asset(filepath.Join(plugdir, d, f))
if err != nil {
continue
}

File diff suppressed because one or more lines are too long