aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/embed
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2021-07-30 14:28:58 -0700
committerIan Lance Taylor <iant@golang.org>2021-08-12 20:23:07 -0700
commitc5b21c3f4c17b0649155035d2f9aa97b2da8a813 (patch)
treec6d3a68b503ba5b16182acbb958e3e5dbc95a43b /libgo/go/embed
parent72be20e20299ec57b4bc9ba03d5b7d6bf10e97cc (diff)
downloadgcc-c5b21c3f4c17b0649155035d2f9aa97b2da8a813.zip
gcc-c5b21c3f4c17b0649155035d2f9aa97b2da8a813.tar.gz
gcc-c5b21c3f4c17b0649155035d2f9aa97b2da8a813.tar.bz2
libgo: update to Go1.17rc2
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/341629
Diffstat (limited to 'libgo/go/embed')
-rw-r--r--libgo/go/embed/embed.go10
-rw-r--r--libgo/go/embed/internal/embedtest/embed_test.go4
-rw-r--r--libgo/go/embed/internal/embedtest/testdata/-not-hidden/fortune.txt2
3 files changed, 9 insertions, 7 deletions
diff --git a/libgo/go/embed/embed.go b/libgo/go/embed/embed.go
index 98da870..851cc21 100644
--- a/libgo/go/embed/embed.go
+++ b/libgo/go/embed/embed.go
@@ -143,7 +143,7 @@ import (
// See the package documentation for more details about initializing an FS.
type FS struct {
// The compiler knows the layout of this struct.
- // See cmd/compile/internal/gc's initEmbed.
+ // See cmd/compile/internal/staticdata's WriteEmbed.
//
// The files list is sorted by name but not by simple string comparison.
// Instead, each file's name takes the form "dir/elem" or "dir/elem/".
@@ -213,7 +213,7 @@ var (
// It implements fs.FileInfo and fs.DirEntry.
type file struct {
// The compiler knows the layout of this struct.
- // See cmd/compile/internal/gc's initEmbed.
+ // See cmd/compile/internal/staticdata's WriteEmbed.
name string
data string
hash [16]byte // truncated SHA256 hash
@@ -386,15 +386,15 @@ func (d *openDir) Read([]byte) (int, error) {
func (d *openDir) ReadDir(count int) ([]fs.DirEntry, error) {
n := len(d.files) - d.offset
- if count > 0 && n > count {
- n = count
- }
if n == 0 {
if count <= 0 {
return nil, nil
}
return nil, io.EOF
}
+ if count > 0 && n > count {
+ n = count
+ }
list := make([]fs.DirEntry, n)
for i := range list {
list[i] = &d.files[d.offset+i]
diff --git a/libgo/go/embed/internal/embedtest/embed_test.go b/libgo/go/embed/internal/embedtest/embed_test.go
index 43ae5c7..2d50f5e 100644
--- a/libgo/go/embed/internal/embedtest/embed_test.go
+++ b/libgo/go/embed/internal/embedtest/embed_test.go
@@ -102,12 +102,12 @@ func TestHidden(t *testing.T) {
t.Logf("//go:embed testdata")
testDir(t, dir, "testdata",
- "ascii.txt", "glass.txt", "hello.txt", "i/", "ken.txt")
+ "-not-hidden/", "ascii.txt", "glass.txt", "hello.txt", "i/", "ken.txt")
t.Logf("//go:embed testdata/*")
testDir(t, star, "testdata",
- ".hidden/", "_hidden/", "ascii.txt", "glass.txt", "hello.txt", "i/", "ken.txt")
+ "-not-hidden/", ".hidden/", "_hidden/", "ascii.txt", "glass.txt", "hello.txt", "i/", "ken.txt")
testDir(t, star, "testdata/.hidden",
"fortune.txt", "more/") // but not .more or _more
diff --git a/libgo/go/embed/internal/embedtest/testdata/-not-hidden/fortune.txt b/libgo/go/embed/internal/embedtest/testdata/-not-hidden/fortune.txt
new file mode 100644
index 0000000..31f2013
--- /dev/null
+++ b/libgo/go/embed/internal/embedtest/testdata/-not-hidden/fortune.txt
@@ -0,0 +1,2 @@
+WARNING: terminal is not fully functional
+ - (press RETURN)