//go:build unix
-package os
-
-import "syscall"
+package syscall
// Some systems set an artificially low soft limit on open file count, for compatibility
// with code that uses select and its hard-coded maximum file descriptor
// Code that really wants Go to leave the limit alone can set the hard limit,
// which Go of course has no choice but to respect.
func init() {
- var lim syscall.Rlimit
- if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &lim); err == nil && lim.Cur != lim.Max {
+ var lim Rlimit
+ if err := Getrlimit(RLIMIT_NOFILE, &lim); err == nil && lim.Cur != lim.Max {
lim.Cur = lim.Max
adjustFileLimit(&lim)
- syscall.Setrlimit(syscall.RLIMIT_NOFILE, &lim)
+ Setrlimit(RLIMIT_NOFILE, &lim)
}
}
//go:build darwin
-package os
-
-import "syscall"
+package syscall
// adjustFileLimit adds per-OS limitations on the Rlimit used for RLIMIT_NOFILE. See rlimit.go.
-func adjustFileLimit(lim *syscall.Rlimit) {
+func adjustFileLimit(lim *Rlimit) {
// On older macOS, setrlimit(RLIMIT_NOFILE, lim) with lim.Cur = infinity fails.
// Set to the value of kern.maxfilesperproc instead.
- n, err := syscall.SysctlUint32("kern.maxfilesperproc")
+ n, err := SysctlUint32("kern.maxfilesperproc")
if err != nil {
return
}
//go:build aix || dragonfly || freebsd || linux || netbsd || openbsd || solaris
-package os
-
-import "syscall"
+package syscall
// adjustFileLimit adds per-OS limitations on the Rlimit used for RLIMIT_NOFILE. See rlimit.go.
-func adjustFileLimit(lim *syscall.Rlimit) {}
+func adjustFileLimit(lim *Rlimit) {}
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package os_test
+package syscall_test
import (
- . "os"
+ "os"
"runtime"
"testing"
)
fileCount = 768
}
- var files []*File
+ var files []*os.File
for i := 0; i < fileCount; i++ {
- f, err := Open("rlimit.go")
+ f, err := os.Open("rlimit.go")
if err != nil {
t.Error(err)
break