Kaynağa Gözat

There is no need to set rlimit in go 1.19

tags/v2.1.7^2
9seconds 3 yıl önce
ebeveyn
işleme
5ad64390d6
3 değiştirilmiş dosya ile 0 ekleme ve 38 silme
  1. 0
    25
      internal/utils/rlimit.go
  2. 0
    8
      internal/utils/rlimit_windows.go
  3. 0
    5
      main.go

+ 0
- 25
internal/utils/rlimit.go Dosyayı Görüntüle

1
-//go:build !windows
2
-// +build !windows
3
-
4
-package utils
5
-
6
-import (
7
-	"fmt"
8
-
9
-	"golang.org/x/sys/unix"
10
-)
11
-
12
-func SetLimits() error {
13
-	rLimit := unix.Rlimit{}
14
-	if err := unix.Getrlimit(unix.RLIMIT_NOFILE, &rLimit); err != nil {
15
-		return fmt.Errorf("cannot get rlimit: %w", err)
16
-	}
17
-
18
-	rLimit.Cur = rLimit.Max
19
-
20
-	if err := unix.Setrlimit(unix.RLIMIT_NOFILE, &rLimit); err != nil {
21
-		return fmt.Errorf("cannot set rlimit: %w", err)
22
-	}
23
-
24
-	return nil
25
-}

+ 0
- 8
internal/utils/rlimit_windows.go Dosyayı Görüntüle

1
-//go:build windows
2
-// +build windows
3
-
4
-package utils
5
-
6
-func SetLimits() error {
7
-	return nil
8
-}

+ 0
- 5
main.go Dosyayı Görüntüle

13
 	"time"
13
 	"time"
14
 
14
 
15
 	"github.com/9seconds/mtg/v2/internal/cli"
15
 	"github.com/9seconds/mtg/v2/internal/cli"
16
-	"github.com/9seconds/mtg/v2/internal/utils"
17
 	"github.com/alecthomas/kong"
16
 	"github.com/alecthomas/kong"
18
 )
17
 )
19
 
18
 
20
 func main() {
19
 func main() {
21
 	rand.Seed(time.Now().UTC().UnixNano())
20
 	rand.Seed(time.Now().UTC().UnixNano())
22
 
21
 
23
-	if err := utils.SetLimits(); err != nil {
24
-		panic(err)
25
-	}
26
-
27
 	cli := &cli.CLI{}
22
 	cli := &cli.CLI{}
28
 	ctx := kong.Parse(cli, kong.Vars{
23
 	ctx := kong.Parse(cli, kong.Vars{
29
 		"version": getVersion(),
24
 		"version": getVersion(),

Loading…
İptal
Kaydet