forked from mirror/afero
Eliminate go vet warnings
This commit is contained in:
parent
90dd71edc4
commit
72b3142684
26
basepath.go
26
basepath.go
|
@ -52,7 +52,7 @@ func validateBasePathName(name string) error {
|
|||
// On Windows a common mistake would be to provide an absolute OS path
|
||||
// We could strip out the base part, but that would not be very portable.
|
||||
if filepath.IsAbs(name) {
|
||||
return &os.PathError{"realPath", name, errors.New("got a real OS path instead of a virtual")}
|
||||
return &os.PathError{Op: "realPath", Path: name, Err: errors.New("got a real OS path instead of a virtual")}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -60,14 +60,14 @@ func validateBasePathName(name string) error {
|
|||
|
||||
func (b *BasePathFs) Chtimes(name string, atime, mtime time.Time) (err error) {
|
||||
if name, err = b.RealPath(name); err != nil {
|
||||
return &os.PathError{"chtimes", name, err}
|
||||
return &os.PathError{Op: "chtimes", Path: name, Err: err}
|
||||
}
|
||||
return b.source.Chtimes(name, atime, mtime)
|
||||
}
|
||||
|
||||
func (b *BasePathFs) Chmod(name string, mode os.FileMode) (err error) {
|
||||
if name, err = b.RealPath(name); err != nil {
|
||||
return &os.PathError{"chmod", name, err}
|
||||
return &os.PathError{Op: "chmod", Path: name, Err: err}
|
||||
}
|
||||
return b.source.Chmod(name, mode)
|
||||
}
|
||||
|
@ -78,66 +78,66 @@ func (b *BasePathFs) Name() string {
|
|||
|
||||
func (b *BasePathFs) Stat(name string) (fi os.FileInfo, err error) {
|
||||
if name, err = b.RealPath(name); err != nil {
|
||||
return nil, &os.PathError{"stat", name, err}
|
||||
return nil, &os.PathError{Op: "stat", Path: name, Err: err}
|
||||
}
|
||||
return b.source.Stat(name)
|
||||
}
|
||||
|
||||
func (b *BasePathFs) Rename(oldname, newname string) (err error) {
|
||||
if oldname, err = b.RealPath(oldname); err != nil {
|
||||
return &os.PathError{"rename", oldname, err}
|
||||
return &os.PathError{Op: "rename", Path: oldname, Err: err}
|
||||
}
|
||||
if newname, err = b.RealPath(newname); err != nil {
|
||||
return &os.PathError{"rename", newname, err}
|
||||
return &os.PathError{Op: "rename", Path: newname, Err: err}
|
||||
}
|
||||
return b.source.Rename(oldname, newname)
|
||||
}
|
||||
|
||||
func (b *BasePathFs) RemoveAll(name string) (err error) {
|
||||
if name, err = b.RealPath(name); err != nil {
|
||||
return &os.PathError{"remove_all", name, err}
|
||||
return &os.PathError{Op: "remove_all", Path: name, Err: err}
|
||||
}
|
||||
return b.source.RemoveAll(name)
|
||||
}
|
||||
|
||||
func (b *BasePathFs) Remove(name string) (err error) {
|
||||
if name, err = b.RealPath(name); err != nil {
|
||||
return &os.PathError{"remove", name, err}
|
||||
return &os.PathError{Op: "remove", Path: name, Err: err}
|
||||
}
|
||||
return b.source.Remove(name)
|
||||
}
|
||||
|
||||
func (b *BasePathFs) OpenFile(name string, flag int, mode os.FileMode) (f File, err error) {
|
||||
if name, err = b.RealPath(name); err != nil {
|
||||
return nil, &os.PathError{"openfile", name, err}
|
||||
return nil, &os.PathError{Op: "openfile", Path: name, Err: err}
|
||||
}
|
||||
return b.source.OpenFile(name, flag, mode)
|
||||
}
|
||||
|
||||
func (b *BasePathFs) Open(name string) (f File, err error) {
|
||||
if name, err = b.RealPath(name); err != nil {
|
||||
return nil, &os.PathError{"open", name, err}
|
||||
return nil, &os.PathError{Op: "open", Path: name, Err: err}
|
||||
}
|
||||
return b.source.Open(name)
|
||||
}
|
||||
|
||||
func (b *BasePathFs) Mkdir(name string, mode os.FileMode) (err error) {
|
||||
if name, err = b.RealPath(name); err != nil {
|
||||
return &os.PathError{"mkdir", name, err}
|
||||
return &os.PathError{Op: "mkdir", Path: name, Err: err}
|
||||
}
|
||||
return b.source.Mkdir(name, mode)
|
||||
}
|
||||
|
||||
func (b *BasePathFs) MkdirAll(name string, mode os.FileMode) (err error) {
|
||||
if name, err = b.RealPath(name); err != nil {
|
||||
return &os.PathError{"mkdir", name, err}
|
||||
return &os.PathError{Op: "mkdir", Path: name, Err: err}
|
||||
}
|
||||
return b.source.MkdirAll(name, mode)
|
||||
}
|
||||
|
||||
func (b *BasePathFs) Create(name string) (f File, err error) {
|
||||
if name, err = b.RealPath(name); err != nil {
|
||||
return nil, &os.PathError{"create", name, err}
|
||||
return nil, &os.PathError{Op: "create", Path: name, Err: err}
|
||||
}
|
||||
return b.source.Create(name)
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ func TestNestedDirBaseReaddir(t *testing.T) {
|
|||
fh, _ = ufs.Open("/home/test/foo")
|
||||
list, err := fh.Readdir(-1)
|
||||
if err != nil {
|
||||
t.Errorf("Readdir failed", err)
|
||||
t.Errorf("Readdir failed %s", err)
|
||||
}
|
||||
if len(list) != 2 {
|
||||
for _, x := range list {
|
||||
|
@ -220,7 +220,7 @@ func TestNestedDirOverlayReaddir(t *testing.T) {
|
|||
fh, _ = ufs.Open("/home/test/foo")
|
||||
list, err := fh.Readdir(-1)
|
||||
if err != nil {
|
||||
t.Errorf("Readdir failed", err)
|
||||
t.Errorf("Readdir failed %s", err)
|
||||
}
|
||||
if len(list) != 2 {
|
||||
for _, x := range list {
|
||||
|
@ -255,7 +255,7 @@ func TestNestedDirOverlayOsFsReaddir(t *testing.T) {
|
|||
list, err := fh.Readdir(-1)
|
||||
fh.Close()
|
||||
if err != nil {
|
||||
t.Errorf("Readdir failed", err)
|
||||
t.Errorf("Readdir failed %s", err)
|
||||
}
|
||||
if len(list) != 2 {
|
||||
for _, x := range list {
|
||||
|
|
|
@ -186,7 +186,7 @@ func (f *File) Truncate(size int64) error {
|
|||
return ErrFileClosed
|
||||
}
|
||||
if f.readOnly {
|
||||
return &os.PathError{"truncate", f.fileData.name, errors.New("file handle is read only")}
|
||||
return &os.PathError{Op: "truncate", Path: f.fileData.name, Err: errors.New("file handle is read only")}
|
||||
}
|
||||
if size < 0 {
|
||||
return ErrOutOfRange
|
||||
|
@ -218,7 +218,7 @@ func (f *File) Seek(offset int64, whence int) (int64, error) {
|
|||
|
||||
func (f *File) Write(b []byte) (n int, err error) {
|
||||
if f.readOnly {
|
||||
return 0, &os.PathError{"write", f.fileData.name, errors.New("file handle is read only")}
|
||||
return 0, &os.PathError{Op: "write", Path: f.fileData.name, Err: errors.New("file handle is read only")}
|
||||
}
|
||||
n = len(b)
|
||||
cur := atomic.LoadInt64(&f.at)
|
||||
|
|
20
memmap.go
20
memmap.go
|
@ -45,7 +45,7 @@ func (m *MemMapFs) getData() map[string]*mem.FileData {
|
|||
return m.data
|
||||
}
|
||||
|
||||
func (MemMapFs) Name() string { return "MemMapFS" }
|
||||
func (*MemMapFs) Name() string { return "MemMapFS" }
|
||||
|
||||
func (m *MemMapFs) Create(name string) (File, error) {
|
||||
name = normalizePath(name)
|
||||
|
@ -108,7 +108,7 @@ func (m *MemMapFs) lockfreeMkdir(name string, perm os.FileMode) error {
|
|||
x, ok := m.getData()[name]
|
||||
if ok {
|
||||
// Only return ErrFileExists if it's a file, not a directory.
|
||||
i := mem.FileInfo{x}
|
||||
i := mem.FileInfo{FileData: x}
|
||||
if !i.IsDir() {
|
||||
return ErrFileExists
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ func (m *MemMapFs) Mkdir(name string, perm os.FileMode) error {
|
|||
_, ok := m.getData()[name]
|
||||
m.mu.RUnlock()
|
||||
if ok {
|
||||
return &os.PathError{"mkdir", name, ErrFileExists}
|
||||
return &os.PathError{Op: "mkdir", Path: name, Err: ErrFileExists}
|
||||
}
|
||||
|
||||
m.mu.Lock()
|
||||
|
@ -190,7 +190,7 @@ func (m *MemMapFs) open(name string) (*mem.FileData, error) {
|
|||
f, ok := m.getData()[name]
|
||||
m.mu.RUnlock()
|
||||
if !ok {
|
||||
return nil, &os.PathError{"open", name, ErrFileNotFound}
|
||||
return nil, &os.PathError{Op: "open", Path: name, Err: ErrFileNotFound}
|
||||
}
|
||||
return f, nil
|
||||
}
|
||||
|
@ -247,11 +247,11 @@ func (m *MemMapFs) Remove(name string) error {
|
|||
if _, ok := m.getData()[name]; ok {
|
||||
err := m.unRegisterWithParent(name)
|
||||
if err != nil {
|
||||
return &os.PathError{"remove", name, err}
|
||||
return &os.PathError{Op: "remove", Path: name, Err: err}
|
||||
}
|
||||
delete(m.getData(), name)
|
||||
} else {
|
||||
return &os.PathError{"remove", name, os.ErrNotExist}
|
||||
return &os.PathError{Op: "remove", Path: name, Err: os.ErrNotExist}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ func (m *MemMapFs) Rename(oldname, newname string) error {
|
|||
m.mu.Unlock()
|
||||
m.mu.RLock()
|
||||
} else {
|
||||
return &os.PathError{"rename", oldname, ErrFileNotFound}
|
||||
return &os.PathError{Op: "rename", Path: oldname, Err: ErrFileNotFound}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ func (m *MemMapFs) Chmod(name string, mode os.FileMode) error {
|
|||
f, ok := m.getData()[name]
|
||||
m.mu.RUnlock()
|
||||
if !ok {
|
||||
return &os.PathError{"chmod", name, ErrFileNotFound}
|
||||
return &os.PathError{Op: "chmod", Path: name, Err: ErrFileNotFound}
|
||||
}
|
||||
|
||||
m.mu.Lock()
|
||||
|
@ -337,7 +337,7 @@ func (m *MemMapFs) Chtimes(name string, atime time.Time, mtime time.Time) error
|
|||
f, ok := m.getData()[name]
|
||||
m.mu.RUnlock()
|
||||
if !ok {
|
||||
return &os.PathError{"chtimes", name, ErrFileNotFound}
|
||||
return &os.PathError{Op: "chtimes", Path: name, Err: ErrFileNotFound}
|
||||
}
|
||||
|
||||
m.mu.Lock()
|
||||
|
@ -349,7 +349,7 @@ func (m *MemMapFs) Chtimes(name string, atime time.Time, mtime time.Time) error
|
|||
|
||||
func (m *MemMapFs) List() {
|
||||
for _, x := range m.data {
|
||||
y := mem.FileInfo{x}
|
||||
y := mem.FileInfo{FileData: x}
|
||||
fmt.Println(x.Name(), y.Size())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,8 +105,8 @@ func checkPathError(t *testing.T, err error, op string) {
|
|||
// Ensure Permissions are set on OpenFile/Mkdir/MkdirAll
|
||||
func TestPermSet(t *testing.T) {
|
||||
const fileName = "/myFileTest"
|
||||
const dirPath = "/myDirTest"
|
||||
const dirPathAll = "/my/path/to/dir"
|
||||
const dirPath = "/myDirTest"
|
||||
const dirPathAll = "/my/path/to/dir"
|
||||
|
||||
const fileMode = os.FileMode(0765)
|
||||
|
||||
|
|
Loading…
Reference in New Issue