package embed import ( "embed" "fmt" "os" "path/filepath" "text/template" ) //go:embed home.html var HomeTemplateString string //go:embed assets/index.css //go:embed assets/index.js var folder embed.FS func Embed() { cssBytes, err := folder.ReadFile(filepath.Join("assets", "index.css")) check(err) jsBytes, err := folder.ReadFile(filepath.Join("assets", "index.js")) check(err) fmt.Println("index.css:") fmt.Println(string(cssBytes)) fmt.Println("index.js:") fmt.Println(string(jsBytes)) fmt.Println("Parsing template and printing it:") t := template.Must(template.New("home").Parse(HomeTemplateString)) t.Execute(os.Stdout, string("John")) } func check(err error) { if err != nil { panic(err) } }