Categorygithub.com/visualfc/goembed
modulepackage
0.3.3
Repository: https://github.com/visualfc/goembed.git
Documentation: pkg.go.dev

# README

goembed

goembed is Golang go:embed parse package

Go1.16 Go1.17 Go1.18 Go1.19

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)
		}
	}
}

# Packages

No description provided by the author
Package fsys is an abstraction for reading files that allows for virtual overlays on top of the files on disk.
No description provided by the author
No description provided by the author

# Functions

BuildFS is build files to new files list with directory.
No description provided by the author
No description provided by the author
CheckEmbed lookup go:embed vars for embedPatternPos.
NewResolve create load embed data interface.
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
may be alias string or []byte.
No description provided by the author
No description provided by the author

# Structs

Embed describes go:embed variable.
File is embed data info.

# Interfaces

Resolve is load embed data interface.

# Type aliases

Kind is embed var type kind.