mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-24 09:47:19 +09:00
Build : using go:generate and go:embed (#2195)
* using go:generate and go:embed * fix import
This commit is contained in:
31
runtime/runtime.go
Normal file
31
runtime/runtime.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"strings"
|
||||
)
|
||||
|
||||
//go:generate go run syntax/make_headers.go syntax
|
||||
|
||||
//go:embed colorschemes help plugins syntax
|
||||
var runtime embed.FS
|
||||
|
||||
// AssetDir lists file names in folder
|
||||
func AssetDir(name string) ([]string, error) {
|
||||
name = strings.TrimLeft(name, "runtime/")
|
||||
entries, err := runtime.ReadDir(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
names := make([]string, len(entries), len(entries))
|
||||
for i, entry := range entries {
|
||||
names[i] = entry.Name()
|
||||
}
|
||||
return names, nil
|
||||
}
|
||||
|
||||
// Asset returns a file content
|
||||
func Asset(name string) ([]byte, error) {
|
||||
name = strings.TrimLeft(name, "runtime/")
|
||||
return runtime.ReadFile(name)
|
||||
}
|
||||
Reference in New Issue
Block a user