From 70938eb6e67e155d63c781d956893fe2c91b2979 Mon Sep 17 00:00:00 2001 From: Dmitry Sovetin Date: Tue, 28 Apr 2020 11:19:30 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D0=B0=D1=8F=20=20GOMAXPROCS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 13c8c08..8889350 100644 --- a/main.go +++ b/main.go @@ -30,12 +30,18 @@ func lstn(connection *net.UDPConn, alarm chan struct{}) { } func main() { + envFlag := runtime.GOMAXPROCS(runtime.NumCPU()) + if envFlag > -1 { + fmt.Println("GOMAXPROCS =", runtime.NumCPU()) + } else { + fmt.Println("GOMAXPROCS is default!") + } argIP := flag.String("ip", "0.0.0.0", "Listen IP address") argPort := flag.Int("port", 10003, "Listen Port number") flag.Parse() - fmt.Println("IP Address: ", *argIP) - fmt.Println("Port Number: ", *argPort) + fmt.Println("IP Address:", *argIP) + fmt.Println("Port Number:", *argPort) addr := net.UDPAddr{ Port: *argPort, @@ -46,7 +52,7 @@ func main() { panic(err) } alarm := make(chan struct{}) - fmt.Println("CPU Threads: ", runtime.NumCPU()) + fmt.Println("CPU Threads:", runtime.NumCPU()) for i := 0; i < runtime.NumCPU(); i++ { go lstn(connection, alarm) }