diff --git a/godoc/vfs/zipfs/zipfs.go b/godoc/vfs/zipfs/zipfs.go index ca69d8c8..e554446e 100644 --- a/godoc/vfs/zipfs/zipfs.go +++ b/godoc/vfs/zipfs/zipfs.go @@ -112,7 +112,7 @@ func (fs *zipFS) stat(abspath string) (int, zipFI, error) { i, exact := fs.list.lookup(zippath) if i < 0 { // zippath has leading '/' stripped - print it explicitly - return -1, zipFI{}, fmt.Errorf("file not found: /%s", zippath) + return -1, zipFI{}, &os.PathError{Path: "/" + zippath, Err: os.ErrNotExist} } _, name := path.Split(zippath) var file *zip.File diff --git a/godoc/vfs/zipfs/zipfs_test.go b/godoc/vfs/zipfs/zipfs_test.go index 57efb49d..19407e48 100644 --- a/godoc/vfs/zipfs/zipfs_test.go +++ b/godoc/vfs/zipfs/zipfs_test.go @@ -150,6 +150,16 @@ func TestZipFSStatFuncs(t *testing.T) { } } +func TestZipFSNotExist(t *testing.T) { + _, err := fs.Open("/does-not-exist") + if err == nil { + t.Fatalf("Expected an error.\n") + } + if !os.IsNotExist(err) { + t.Errorf("Expected an error satisfying os.IsNotExist: %v\n", err) + } +} + func TestZipFSOpenSeek(t *testing.T) { for _, test := range tests { if test.IsRegular {