mirror of
https://github.com/MADTeacher/go_basics.git
synced 2025-11-23 21:34:47 +02:00
Глава 8
Допричесать игру
This commit is contained in:
38
part_8/8.2/tcp/main.go
Normal file
38
part_8/8.2/tcp/main.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
"udp/server/client"
|
||||
"udp/server/server"
|
||||
)
|
||||
|
||||
const PORT = 8081
|
||||
|
||||
func checkErr(err error) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
if len(os.Args) != 2 {
|
||||
fmt.Println("You didn't select a launch option!!!")
|
||||
return
|
||||
}
|
||||
numGR, err := strconv.Atoi(os.Args[1])
|
||||
checkErr(err)
|
||||
|
||||
switch numGR {
|
||||
case 1:
|
||||
fmt.Println("Server is running")
|
||||
server.RunServer(PORT)
|
||||
case 2:
|
||||
fmt.Println("Client is running")
|
||||
client.RunClient(PORT)
|
||||
default:
|
||||
log.Fatal("What pokemon is this?")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user