-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
65 lines (57 loc) · 1.21 KB
/
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
58
59
60
61
62
63
64
65
package main
import (
"fmt"
"github.com/ExchangeUnion/xud-launcher/core"
"github.com/mitchellh/go-homedir"
"os"
"path/filepath"
"runtime"
)
func main() {
homeDir, err := GetHomeDir()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
r, err := core.NewLauncher(homeDir)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
network := GetNetwork()
networkDir := filepath.Join(homeDir, network)
branch := GetBranch()
err = r.Start(branch, network, networkDir, os.Args...)
if err != nil {
fmt.Printf("ERROR: %s\n", err)
os.Exit(1)
}
}
func GetHomeDir() (string, error) {
homeDir, err := homedir.Dir()
if err != nil {
panic(err)
}
switch runtime.GOOS {
case "linux":
return filepath.Join(homeDir, ".xud-docker"), nil
case "darwin":
return filepath.Join(homeDir, "Library", "Application Support", "XudDocker"), nil
case "windows":
return filepath.Join(homeDir, "AppData", "Local", "XudDocker"), nil
default:
return "", fmt.Errorf("unsupported platform: %s", runtime.GOOS)
}
}
func GetNetwork() string {
if value, ok := os.LookupEnv("NETWORK"); ok {
return value
}
return "mainnet"
}
func GetBranch() string {
if value, ok := os.LookupEnv("BRANCH"); ok {
return value
}
return "master"
}