You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
656 B

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