-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.go
59 lines (52 loc) · 1.06 KB
/
util.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
package go_portal_p4
import (
"encoding/json"
"errors"
"fmt"
"log"
"os/exec"
"reflect"
"runtime"
"team529.nl/go-portal-p4/portal-p4/messages"
)
func AssertPointer(v interface{}, message string) error {
val := reflect.ValueOf(v)
if val.Kind() != reflect.Ptr {
return errors.New(message)
}
return nil
}
func PrettyPrint(data interface{}) {
var p []byte
// var err := error
p, err := json.MarshalIndent(data, "", "\t")
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("%s \n", p)
}
type TestConfig struct {
Env string
CertificatePath string
PrivateKeyPath string
SenderEAN string
ReceiverEAN string
EanCodes []messages.GSRNEANCode
}
func OpenBrowser(url string) {
var err error
switch runtime.GOOS {
case "linux":
err = exec.Command("xdg-open", url).Start()
case "windows":
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
case "darwin":
err = exec.Command("open", url).Start()
default:
err = fmt.Errorf("unsupported platform")
}
if err != nil {
log.Fatal(err)
}
}