first commit

This commit is contained in:
José David Guillén 2021-09-14 19:02:40 +00:00
commit 6dc292e989
4 changed files with 55 additions and 0 deletions

8
assets/report.html Normal file
View File

@ -0,0 +1,8 @@
<html>
<head>
<title>{{$.Title}}</title>
</head>
<body>
<h1>Go is cool af!</h1>
</body>
</html>

26
fs-demo.go Normal file
View File

@ -0,0 +1,26 @@
package main
import (
"embed"
"fmt"
"html/template"
"os"
)
//go:embed assets/*
var assetData embed.FS
func main() {
t, err := template.ParseFS(assetData, "assets/report.html")
if err != nil {
fmt.Println(err)
}
templateData := struct {
Title string
}{
Title: "File inside Go",
}
t.Execute(os.Stdout, templateData)
}

4
sample.txt Normal file
View File

@ -0,0 +1,4 @@
This is a sample file
with multiple lines
and 🐧️ emojis too!

17
static-demo.go Normal file
View File

@ -0,0 +1,17 @@
package main
import (
_ "embed"
"fmt"
)
//go:embed sample.txt
var s string
func main() {
// //go:embed sample.txt
// var s string
fmt.Println(s)
}