commonroutesServer/tests/readConfig.go
tests/readConfig.goRaw
1package main
2
3import (
4 "encoding/json"
5 "fmt"
6 "io/ioutil"
7)
8
9type Config struct {
10 Url string `json:"url"`
11}
12
13var config Config
14
15type User struct {
16 Username string `json:"username"`
17 Password string `json:"password"`
18 Email string `json:"email"`
19 Token string `json:"token"`
20}
21
22var users []User
23
24func readUsers() {
25 file, e := ioutil.ReadFile("users.json")
26 if e != nil {
27 fmt.Println("error:", e)
28 }
29 content := string(file)
30 json.Unmarshal([]byte(content), &users)
31}
32func readConfig() {
33 file, e := ioutil.ReadFile("config.json")
34 if e != nil {
35 fmt.Println("error:", e)
36 }
37 content := string(file)
38 json.Unmarshal([]byte(content), &config)
39}