generated from moul/golang-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from moul/dev/moul/is-too-many-error
feat: add IsTooManyError helper
- Loading branch information
Showing
4 changed files
with
99 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,36 @@ | ||
GOPKG ?= moul.io/openfiles | ||
|
||
.PHONY: test-archs | ||
test-archs: | ||
GOOS=darwin GOARCH=386 go test -v -c -o /dev/null | ||
GOOS=darwin GOARCH=amd64 go test -v -c -o /dev/null | ||
GOOS=linux GOARCH=386 go test -v -c -o /dev/null | ||
GOOS=linux GOARCH=amd64 go test -v -c -o /dev/null | ||
GOOS=linux GOARCH=arm go test -v -c -o /dev/null | ||
GOOS=linux GOARCH=arm64 go test -v -c -o /dev/null | ||
GOOS=linux GOARCH=ppc64 go test -v -c -o /dev/null | ||
GOOS=linux GOARCH=ppc64le go test -v -c -o /dev/null | ||
GOOS=linux GOARCH=mips go test -v -c -o /dev/null | ||
GOOS=linux GOARCH=mipsle go test -v -c -o /dev/null | ||
GOOS=linux GOARCH=mips64 go test -v -c -o /dev/null | ||
GOOS=linux GOARCH=mips64le go test -v -c -o /dev/null | ||
GOOS=linux GOARCH=s390x go test -v -c -o /dev/null | ||
GOOS=js GOARCH=wasm go test -v -c -o /dev/null | ||
GOOS=dragonfly GOARCH=amd64 go test -v -c -o /dev/null | ||
GOOS=freebsd GOARCH=386 go test -v -c -o /dev/null | ||
GOOS=freebsd GOARCH=amd64 go test -v -c -o /dev/null | ||
GOOS=freebsd GOARCH=arm go test -v -c -o /dev/null | ||
GOOS=netbsd GOARCH=386 go test -v -c -o /dev/null | ||
GOOS=netbsd GOARCH=amd64 go test -v -c -o /dev/null | ||
GOOS=netbsd GOARCH=arm go test -v -c -o /dev/null | ||
GOOS=openbsd GOARCH=386 go test -v -c -o /dev/null | ||
GOOS=openbsd GOARCH=amd64 go test -v -c -o /dev/null | ||
GOOS=openbsd GOARCH=arm go test -v -c -o /dev/null | ||
GOOS=plan9 GOARCH=386 go test -v -c -o /dev/null | ||
GOOS=plan9 GOARCH=amd64 go test -v -c -o /dev/null | ||
GOOS=plan9 GOARCH=arm go test -v -c -o /dev/null | ||
GOOS=solaris GOARCH=amd64 go test -v -c -o /dev/null | ||
GOOS=windows GOARCH=386 go test -v -c -o /dev/null | ||
GOOS=windows GOARCH=amd64 go test -v -c -o /dev/null | ||
|
||
include rules.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,27 @@ | ||
package openfiles | ||
|
||
import "errors" | ||
import ( | ||
"errors" | ||
"os" | ||
"syscall" | ||
) | ||
|
||
// ErrNotSupported indicates an unsupported GOOS or GOARCH | ||
var ErrNotSupported = errors.New("not supported environment") | ||
var ( | ||
// ErrNotSupported is raised on an unsupported GOOS or GOARCH | ||
ErrNotSupported = errors.New("moul.io/openfiles: not supported environment") | ||
|
||
// ErrInternal represents an internal error | ||
ErrInternal = errors.New("moul.io/openfiles: internal error") | ||
) | ||
|
||
func IsTooManyError(err error) bool { | ||
if err == syscall.EMFILE { | ||
return true | ||
} | ||
|
||
if err, isPathError := err.(*os.PathError); isPathError { | ||
return err.Err == syscall.EMFILE | ||
} | ||
|
||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters