-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtimeline.go
46 lines (39 loc) · 848 Bytes
/
timeline.go
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
45
46
package main
import (
"flag"
"fmt"
"os"
"path/filepath"
"sync"
)
func main() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: ./%s [<JSON file> [<JSON file>]]\n", filepath.Base(os.Args[0]))
flag.PrintDefaults()
os.Exit(0)
}
certificate := flag.String("c", "cert.pem", "TLS server certificate")
key := flag.String("k", "key.pem", "TLS server key")
hostname := flag.String("n", "localhost", "Hostname")
port := flag.Int("p", 8443, "listen on port")
flag.Parse()
args := flag.Args()
if len(args) == 0 {
serve(*certificate, *key, *hostname, *port)
return
}
ch := make(chan ShortResult)
for _, input := range args {
go processFile(input, ch)
}
var mu sync.Mutex
var code int
for range args {
result := <-ch
mu.Lock()
code += result.Code
mu.Unlock()
fmt.Println(result.Message)
}
os.Exit(code)
}