Skip to content

Commit

Permalink
chore: replace os.(FileMode,PathError) by fs.(...) (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored Jul 2, 2024
1 parent eccd827 commit e49f343
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
7 changes: 4 additions & 3 deletions flock.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package flock

import (
"context"
"io/fs"
"os"
"runtime"
"sync"
Expand All @@ -35,7 +36,7 @@ func SetFlag(flag int) Option {
}

// SetPermissions sets the OS permissions to set on the file.
func SetPermissions(perm os.FileMode) Option {
func SetPermissions(perm fs.FileMode) Option {
return func(f *Flock) {
f.perm = perm
}
Expand All @@ -53,7 +54,7 @@ type Flock struct {
// flag is the flag used to create/open the file.
flag int
// perm is the OS permissions to set on the file.
perm os.FileMode
perm fs.FileMode
}

// New returns a new instance of *Flock. The only parameter
Expand All @@ -72,7 +73,7 @@ func New(path string, opts ...Option) *Flock {
f := &Flock{
path: path,
flag: flags,
perm: os.FileMode(0o600),
perm: fs.FileMode(0o600),
}

for _, opt := range opts {
Expand Down
5 changes: 2 additions & 3 deletions flock_unix_fcntl.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package flock
import (
"errors"
"io"
"os"
"io/fs"
"sync"
"syscall"

Expand Down Expand Up @@ -144,8 +144,7 @@ func (f *Flock) doLock(cmd cmdType, lt lockType, blocking bool) (bool, error) {

if i, dup := inodes[f]; dup && i != ino {
mu.Unlock()

return false, &os.PathError{
return false, &fs.PathError{
Op: lt.String(),
Path: f.Path(),
Err: errors.New("inode for file changed since last Lock or RLock"),
Expand Down

0 comments on commit e49f343

Please sign in to comment.