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

add support for illumos/solaris #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion flock.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (f *Flock) setFh() error {
// open a new os.File instance
// create it if it doesn't exist, and open the file read-only.
flags := os.O_CREATE
if runtime.GOOS == "aix" {
if runtime.GOOS == "aix" || runtime.GOOS == "solaris" || runtime.GOOS == "illumos" {
// AIX cannot preform write-lock (ie exclusive) on a
// read-only file.
flags |= os.O_RDWR
Expand Down
2 changes: 1 addition & 1 deletion flock_aix.go → flock_aix_solaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// This code is adapted from the Go package:
// cmd/go/internal/lockedfile/internal/filelock

//+build aix
//+build aix solaris

package flock

Expand Down
2 changes: 1 addition & 1 deletion flock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (t *TestSuite) TestFlock_TryRLock(c *C) {
flock2 := flock.New(t.path)
locked, err = flock2.TryRLock()
c.Assert(err, IsNil)
if runtime.GOOS == "aix" {
if runtime.GOOS == "aix" || runtime.GOOS == "solaris" || runtime.GOOS == "illumos" {
// When using POSIX locks, we can't safely read-lock the same
// inode through two different descriptors at the same time:
// when the first descriptor is closed, the second descriptor
Expand Down
2 changes: 1 addition & 1 deletion flock_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by the BSD 3-Clause
// license that can be found in the LICENSE file.

// +build !aix,!windows
// +build !aix,!windows,!solaris

package flock

Expand Down
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/gofrs/flock

go 1.15

require (
golang.org/x/sys v0.0.0-20210313202042-bd2e13477e9c
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c
)
9 changes: 9 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
golang.org/x/sys v0.0.0-20210313202042-bd2e13477e9c h1:coiPEfMv+ThsjULRDygLrJVlNE1gDdL2g65s0LhV2os=
golang.org/x/sys v0.0.0-20210313202042-bd2e13477e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=