run gofumpt cleanup across code-base (#14015)

This commit is contained in:
Harshavardhana
2022-01-02 09:15:06 -08:00
committed by GitHub
parent 6f474982ed
commit f527c708f2
250 changed files with 1201 additions and 1264 deletions

View File

@@ -25,10 +25,8 @@ import (
"sync"
)
var (
// ErrAlreadyLocked is returned if the underlying fd is already locked.
ErrAlreadyLocked = errors.New("file already locked")
)
// ErrAlreadyLocked is returned if the underlying fd is already locked.
var ErrAlreadyLocked = errors.New("file already locked")
// RLockedFile represents a read locked file, implements a special
// closer which only closes the associated *os.File when the ref count.
@@ -87,13 +85,12 @@ func newRLockedFile(lkFile *LockedFile) (*RLockedFile, error) {
// RLockedOpenFile - returns a wrapped read locked file, if the file
// doesn't exist at path returns an error.
func RLockedOpenFile(path string) (*RLockedFile, error) {
lkFile, err := LockedOpenFile(path, os.O_RDONLY, 0666)
lkFile, err := LockedOpenFile(path, os.O_RDONLY, 0o666)
if err != nil {
return nil, err
}
return newRLockedFile(lkFile)
}
// LockedFile represents a locked file

View File

@@ -47,7 +47,7 @@ func lockedOpenFile(path string, flag int, perm os.FileMode, rlockType int) (*Lo
}
}
var lock = syscall.Flock_t{
lock := syscall.Flock_t{
Start: 0,
Len: 0,
Pid: 0,

View File

@@ -38,7 +38,7 @@ func TestLockFail(t *testing.T) {
}
}()
_, err = LockedOpenFile(f.Name(), os.O_APPEND, 0600)
_, err = LockedOpenFile(f.Name(), os.O_APPEND, 0o600)
if err == nil {
t.Fatal("Should fail here")
}
@@ -57,7 +57,7 @@ func TestLockDirFail(t *testing.T) {
}
}()
_, err = LockedOpenFile(d, os.O_APPEND, 0600)
_, err = LockedOpenFile(d, os.O_APPEND, 0o600)
if err == nil {
t.Fatal("Should fail here")
}
@@ -141,7 +141,7 @@ func TestLockAndUnlock(t *testing.T) {
}()
// lock the file
l, err := LockedOpenFile(f.Name(), os.O_WRONLY, 0600)
l, err := LockedOpenFile(f.Name(), os.O_WRONLY, 0o600)
if err != nil {
t.Fatal(err)
}
@@ -152,7 +152,7 @@ func TestLockAndUnlock(t *testing.T) {
}
// try lock the unlocked file
dupl, err := LockedOpenFile(f.Name(), os.O_WRONLY|os.O_CREATE, 0600)
dupl, err := LockedOpenFile(f.Name(), os.O_WRONLY|os.O_CREATE, 0o600)
if err != nil {
t.Errorf("err = %v, want %v", err, nil)
}
@@ -160,7 +160,7 @@ func TestLockAndUnlock(t *testing.T) {
// blocking on locked file
locked := make(chan struct{}, 1)
go func() {
bl, blerr := LockedOpenFile(f.Name(), os.O_WRONLY, 0600)
bl, blerr := LockedOpenFile(f.Name(), os.O_WRONLY, 0o600)
if blerr != nil {
t.Error(blerr)
return

View File

@@ -251,7 +251,7 @@ func lockFile(fd syscall.Handle, flags uint32) error {
}
func lockFileEx(h syscall.Handle, flags, locklow, lockhigh uint32, ol *syscall.Overlapped) (err error) {
var reserved = uint32(0)
reserved := uint32(0)
r1, _, e1 := syscall.Syscall6(procLockFileEx.Addr(), 6, uintptr(h), uintptr(flags),
uintptr(reserved), uintptr(locklow), uintptr(lockhigh), uintptr(unsafe.Pointer(ol)))
if r1 == 0 {