Skip to content

Commit d82685e

Browse files
authored
feat: add support for Illumos/Solaris (#63)
1 parent e5593aa commit d82685e

File tree

5 files changed

+5
-6
lines changed

5 files changed

+5
-6
lines changed

build.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
# Not supported by flock:
44
# - plan9/*
5-
# - solaris/*
65
# - js/wasm
76
# - wasp1/wasm
87

9-
for row in $(go tool dist list -json | jq -r '.[] | select( .GOOS != "plan9" and .GOOS != "solaris" and .GOARCH != "wasm") | @base64'); do
8+
for row in $(go tool dist list -json | jq -r '.[] | select( .GOOS != "plan9" and .GOARCH != "wasm") | @base64'); do
109
_jq() {
1110
echo ${row} | base64 --decode | jq -r ${1}
1211
}

flock.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (f *Flock) setFh() error {
119119
// open a new os.File instance
120120
// create it if it doesn't exist, and open the file read-only.
121121
flags := os.O_CREATE
122-
if runtime.GOOS == "aix" {
122+
if runtime.GOOS == "aix" || runtime.GOOS == "solaris" || runtime.GOOS == "illumos" {
123123
// AIX cannot preform write-lock (ie exclusive) on a
124124
// read-only file.
125125
flags |= os.O_RDWR

flock_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (s *TestSuite) TestFlock_TryRLock() {
119119
locked, err = flock2.TryRLock()
120120
s.Require().NoError(err)
121121

122-
if runtime.GOOS == "aix" {
122+
if runtime.GOOS == "aix" || runtime.GOOS == "solaris" || runtime.GOOS == "illumos" {
123123
// When using POSIX locks, we can't safely read-lock the same
124124
// inode through two different descriptors at the same time:
125125
// when the first descriptor is closed, the second descriptor

flock_unix.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Use of this source code is governed by the BSD 3-Clause
44
// license that can be found in the LICENSE file.
55

6-
//go:build !aix && !windows
6+
//go:build !aix && !solaris && !windows
77

88
package flock
99

flock_aix.go renamed to flock_unix_variants.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// This code is adapted from the Go package:
1616
// cmd/go/internal/lockedfile/internal/filelock
1717

18-
//go:build aix
18+
//go:build aix || solaris
1919

2020
package flock
2121

0 commit comments

Comments
 (0)