github.com/visualfc/goembed@v0.3.3/README.md (about) 1 # goembed 2 goembed is Golang go:embed parse package 3 4 [![Go1.16](https://github.com/visualfc/goembed/workflows/Go1.16/badge.svg)](https://github.com/visualfc/goembed/actions/workflows/go116.yml) 5 [![Go1.17](https://github.com/visualfc/goembed/workflows/Go1.17/badge.svg)](https://github.com/visualfc/goembed/actions/workflows/go117.yml) 6 [![Go1.18](https://github.com/visualfc/goembed/workflows/Go1.18/badge.svg)](https://github.com/visualfc/goembed/actions/workflows/go118.yml) 7 [![Go1.19](https://github.com/visualfc/goembed/workflows/Go1.19/badge.svg)](https://github.com/visualfc/goembed/actions/workflows/go119.yml) 8 9 10 ### demo 11 ``` 12 package main 13 14 import ( 15 "fmt" 16 "go/ast" 17 "go/build" 18 "go/parser" 19 "go/token" 20 "path/filepath" 21 22 "github.com/visualfc/goembed" 23 ) 24 25 func main() { 26 pkg, err := build.Import("github.com/visualfc/goembed", "", 0) 27 if err != nil { 28 panic(err) 29 } 30 fset := token.NewFileSet() 31 var files []*ast.File 32 for _, file := range pkg.TestGoFiles { 33 f, err := parser.ParseFile(fset, filepath.Join(pkg.Dir, file), nil, 0) 34 if err != nil { 35 panic(err) 36 } 37 files = append(files, f) 38 } 39 ems,err := goembed.CheckEmbed(pkg.TestEmbedPatternPos, fset, files) 40 if err != nil { 41 panic(err) 42 } 43 r := goembed.NewResolve() 44 for _, em := range ems { 45 files, err := r.Load(pkg.Dir, fset, em) 46 if err != nil { 47 panic(err) 48 } 49 for _, f := range files { 50 fmt.Println(f.Name, f.Data, f.Hash) 51 } 52 } 53 } 54 ```