first commit
This commit is contained in:
		
							
								
								
									
										8
									
								
								assets/report.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								assets/report.html
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										26
									
								
								fs-demo.go
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										4
									
								
								sample.txt
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,4 @@
 | 
			
		||||
This is a sample file
 | 
			
		||||
with multiple lines
 | 
			
		||||
 | 
			
		||||
and 🐧️ emojis too!
 | 
			
		||||
							
								
								
									
										17
									
								
								static-demo.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								static-demo.go
									
									
									
									
									
										Normal 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)
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user