-
Notifications
You must be signed in to change notification settings - Fork 2
/
GoNorad.go
57 lines (42 loc) · 891 Bytes
/
GoNorad.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"
"io/ioutil"
"net/http/cookiejar"
"os"
)
type DataRequest struct {
result []string
}
type FileStorage interface {
GetContents()
WriteContents()
}
type CookieFile struct{}
func (*CookieFile) GetContents(fileName string) string {
file, err := ioutil.ReadFile(fileName)
ErrorExit(err)
return string(file)
}
func (*CookieFile) WriteContents(fileName string, contents string) {
err := ioutil.WriteFile(fileName, []byte(contents), 0644)
ErrorExit(err)
}
func main() {
var e error
var np2 = new(Neptune)
config := GetConfig()
cookieJar, e := cookiejar.New(nil)
res, e := np2.Login(config["username"], config["password"], cookieJar)
ErrorExit(e)
fmt.Println(res)
res, e = np2.GetData(config["gameNumber"], cookieJar)
ErrorExit(e)
fmt.Println(res)
}
func ErrorExit(e error) {
if e != nil {
fmt.Println("Error:", e)
os.Exit(1)
}
}