-
Notifications
You must be signed in to change notification settings - Fork 1
/
lib.go
50 lines (42 loc) · 1022 Bytes
/
lib.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
package main
import (
"encoding/json"
"io/ioutil"
"log"
)
type Book struct {
NewData Data `json:"data"`
ErrNo int `json:"errNo"`
}
type BookInfo struct {
BookName string `json:"book_text"`
Author string `json:"author"`
LastNumber string `json:"number"`
LastID string `json:"id"`
UpdateTime string `json:"time"`
}
type Data struct {
BookText string `json:"book_text"`
Title string `json:"title"`
Number int `json:"number"`
ContentImg string `json:"content_img"`
Book int `json:"book"`
}
type Config struct {
LastUpdate int `json:"last_id"`
MailAddress string `json:"mail_address"`
MailPort int `json:"mail_port"`
MailUser string `json:"mail_user"`
MailPassword string `json:"mail_password"`
}
type Subscription struct {
Mail string `json:"mail"`
List []int `json:"list"`
}
func getJson(path string, target interface{}) error {
file, err := ioutil.ReadFile(path)
if err != nil {
log.Panic(err)
}
return json.Unmarshal(file, target)
}