-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
57 lines (52 loc) · 894 Bytes
/
main.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
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"fmt"
"os"
"github.com/mirkochip/get-programming-with-go/common"
exps "github.com/mirkochip/get-programming-with-go/experiments"
)
// Definition of command
type cmd struct {
fn func()
}
// Subcommands playlist
var commandFuncs = map[string]cmd{
"greetings": {
fn: exps.Greetings,
},
"playground": {
fn: exps.Playground,
},
"malacandra": {
fn: exps.Malacandra,
},
"guess": {
fn: exps.Guess,
},
"random-dates": {
fn: exps.RandomDates,
},
"mars-tickets": {
fn: exps.MarsTickets,
},
"piggy": {
fn: exps.Piggy,
},
"piggyInt": {
fn: exps.PiggyInt,
},
"canis": {
fn: exps.Canis,
},
}
func main() {
exp := os.Args[1]
fmt.Printf("Running experiment %s\n", exp)
common.PrintSymbols("#", 29)
cmd, ok := commandFuncs[exp]
if !ok {
fmt.Printf("Argument [%s] not found into the experiments playlist.\n", exp)
return
}
cmd.fn()
}