https://github.com/visualfc/goembed
golang go:embed parse package
https://github.com/visualfc/goembed
embed go golang
Last synced: 2 months ago
JSON representation
golang go:embed parse package
- Host: GitHub
- URL: https://github.com/visualfc/goembed
- Owner: visualfc
- License: bsd-3-clause
- Created: 2021-02-03T23:07:00.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-09-19T00:32:54.000Z (over 3 years ago)
- Last Synced: 2025-04-16T03:53:37.037Z (about 1 year ago)
- Topics: embed, go, golang
- Language: Go
- Homepage:
- Size: 45.9 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# goembed
goembed is Golang go:embed parse package
[](https://github.com/visualfc/goembed/actions/workflows/go.yml)
### demo
```
package main
import (
"fmt"
"go/ast"
"go/build"
"go/parser"
"go/token"
"path/filepath"
"github.com/visualfc/goembed"
)
func main() {
pkg, err := build.Import("github.com/visualfc/goembed", "", 0)
if err != nil {
panic(err)
}
fset := token.NewFileSet()
var files []*ast.File
for _, file := range pkg.TestGoFiles {
f, err := parser.ParseFile(fset, filepath.Join(pkg.Dir, file), nil, 0)
if err != nil {
panic(err)
}
files = append(files, f)
}
ems,err := goembed.CheckEmbed(pkg.TestEmbedPatternPos, fset, files)
if err != nil {
panic(err)
}
r := goembed.NewResolve()
for _, em := range ems {
files, err := r.Load(pkg.Dir, fset, em)
if err != nil {
panic(err)
}
for _, f := range files {
fmt.Println(f.Name, f.Data, f.Hash)
}
}
}
```