Start using new errors package (#8207)

This commit is contained in:
Harshavardhana
2019-09-11 10:21:43 -07:00
committed by kannappanr
parent e12f52e2c6
commit a7be313230
9 changed files with 63 additions and 153 deletions

View File

@@ -19,7 +19,6 @@
package lock
import (
"fmt"
"os"
"syscall"
)
@@ -39,7 +38,11 @@ func lockedOpenFile(path string, flag int, perm os.FileMode, lockType int) (*Loc
case syscall.O_RDWR | syscall.O_CREAT:
lockType |= syscall.LOCK_EX
default:
return nil, fmt.Errorf("Unsupported flag (%d)", flag)
return nil, &os.PathError{
Op: "open",
Path: path,
Err: syscall.EINVAL,
}
}
f, err := os.OpenFile(path, flag|syscall.O_SYNC, perm)

View File

@@ -19,7 +19,6 @@
package lock
import (
"fmt"
"os"
"syscall"
)
@@ -39,7 +38,11 @@ func lockedOpenFile(path string, flag int, perm os.FileMode, rlockType int) (*Lo
case syscall.O_RDWR | syscall.O_CREAT:
lockType = syscall.F_WRLCK
default:
return nil, fmt.Errorf("Unsupported flag (%d)", flag)
return nil, &os.PathError{
Op: "open",
Path: path,
Err: syscall.EINVAL,
}
}
var lock = syscall.Flock_t{