Files
garble/testdata/script/embed.txtar
Daniel Martí 30357af923 drop Go 1.22 and require Go 1.23.0 or later (#876)
This lets us start taking advantage of featurs from Go 1.23,
particularly tracking aliases in go/types and iterators.

Note that we need to add code to properly handle or skip over the new
*types.Alias type which go/types produces for Go type aliases.
Also note that we actually turn this mode off entirely for now,
due to the bug reported at https://go.dev/issue/70394.

We don't yet remove our own alias tracking code yet due to the above.
We hope to be able to remove it very soon.
2024-11-17 16:06:57 +01:00

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"