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.
64 lines
991 B
Plaintext
64 lines
991 B
Plaintext
3 years ago
|
env GOGARBLE=*
|
||
4 years ago
|
|
||
|
garble build
|
||
|
|
||
|
exec ./main
|
||
|
cmp stdout main.stdout
|
||
|
|
||
4 years ago
|
[short] stop # no need to verify this with -short
|
||
|
|
||
|
go build
|
||
|
exec ./main
|
||
|
cmp stdout main.stdout
|
||
|
|
||
4 years ago
|
-- go.mod --
|
||
|
module test/main
|
||
|
|
||
3 years ago
|
go 1.18
|
||
4 years ago
|
|
||
|
-- main.go --
|
||
|
package main
|
||
|
|
||
|
import (
|
||
4 years ago
|
"embed"
|
||
4 years ago
|
"fmt"
|
||
4 years ago
|
"io/fs"
|
||
4 years ago
|
)
|
||
|
|
||
4 years ago
|
//go:embed embed-string.txt
|
||
|
var embedStr string
|
||
|
|
||
|
//go:embed embed-dir
|
||
|
var embedDir embed.FS
|
||
4 years ago
|
|
||
|
func main() {
|
||
4 years ago
|
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
|
||
|
})
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
-- embed-string.txt --
|
||
|
string content
|
||
|
-- embed-dir/file1.txt --
|
||
|
file1 content
|
||
|
-- embed-dir/file2.txt --
|
||
|
file2 content
|
||
4 years ago
|
-- main.stdout --
|
||
4 years ago
|
"string content\n"
|
||
|
embed-dir/file1.txt: "file1 content\n"
|
||
|
embed-dir/file2.txt: "file2 content\n"
|