You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
978 B
Plaintext
60 lines
978 B
Plaintext
exec garble build
|
|
|
|
exec ./main
|
|
cmp stdout main.stdout
|
|
|
|
[short] stop # no need to verify this with -short
|
|
|
|
go build
|
|
exec ./main
|
|
cmp stdout main.stdout
|
|
-- go.mod --
|
|
module test/main
|
|
|
|
go 1.23
|
|
-- main.go --
|
|
package main
|
|
|
|
import (
|
|
"embed"
|
|
"fmt"
|
|
"io/fs"
|
|
)
|
|
|
|
//go:embed embed-string.txt
|
|
var embedStr string
|
|
|
|
//go:embed embed-dir
|
|
var embedDir embed.FS
|
|
|
|
func main() {
|
|
fmt.Printf("%q\n", embedStr)
|
|
|
|
fs.WalkDir(embedDir, ".", func(path string, d fs.DirEntry, err error) error {
|
|
if err != nil {
|
|
fmt.Printf("%s: %v\n", path, err)
|
|
return nil
|
|
}
|
|
if !d.IsDir() {
|
|
body, err := fs.ReadFile(embedDir, path)
|
|
if err != nil {
|
|
fmt.Printf("%s: %v\n", path, err)
|
|
return nil
|
|
}
|
|
fmt.Printf("%s: %q\n", path, body)
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
-- embed-string.txt --
|
|
string content
|
|
-- embed-dir/file1.txt --
|
|
file1 content
|
|
-- embed-dir/file2.txt --
|
|
file2 content
|
|
-- main.stdout --
|
|
"string content\n"
|
|
embed-dir/file1.txt: "file1 content\n"
|
|
embed-dir/file2.txt: "file2 content\n"
|