-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
44 lines (33 loc) · 712 Bytes
/
main.go
File metadata and controls
44 lines (33 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"flag"
"fmt"
"github.com/Codefresh-Examples/multi-containers-in-pod/pkg/demo"
)
func main() {
port := flag.String("port", "1111", "server's port")
runClient := flag.Bool("client", false, "run client")
runServer := flag.Bool("server", true, "run server")
flag.Parse()
fmt.Printf("%v %v %v\n", *port, *runClient, *runServer)
var s chan string
var c chan string
if *runServer {
fmt.Println("start server ...")
go func() {
s = demo.StartServer(*port)
}()
}
if *runClient {
fmt.Println("start client ...")
c = demo.StartClient(*port)
}
for {
select {
case <-c:
fmt.Printf("[client]%s\n", <-c)
case <-s:
fmt.Printf("[server]%s\n", <-s)
}
}
}