// +build !windows

package osfs

import (
	"syscall"
)

func (f *file) Lock() error {
	f.m.Lock()
	defer f.m.Unlock()

	return syscall.Flock(int(f.File.Fd()), syscall.LOCK_EX)
}

func (f *file) Unlock() error {
	f.m.Lock()
	defer f.m.Unlock()

	return syscall.Flock(int(f.File.Fd()), syscall.LOCK_UN)
}

// +build !windows

package osfs

import (
	"golang.org/x/sys/unix"
)

func (f *file) Lock() error {
	f.m.Lock()
	defer f.m.Unlock()

	return unix.Flock(int(f.File.Fd()), unix.LOCK_EX)
}

func (f *file) Unlock() error {
	f.m.Lock()
	defer f.m.Unlock()

	return unix.Flock(int(f.File.Fd()), unix.LOCK_UN)
}

Change Posix File Locking to x/unix
Change Posix File Locking to x/unix

syscall Flock only supports Linux. Use the experimental (not really) unix interface which supports most posix systems properly

Signed-off-by: Till Wegmüller <66e0e48c0ddce54a68253eee164bd68e988b251f@gmail.com>
