Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: replace os.(FileMode,PathError) by fs.(...) #83

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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