basic user data
This commit is contained in:
parent
f8f5b19007
commit
72638cda3a
2 changed files with 31 additions and 0 deletions
27
data/data.go
27
data/data.go
|
@ -1 +1,28 @@
|
||||||
package data
|
package data
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/gookit/goutil/jsonutil"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
Users = make(map[string]User)
|
||||||
|
)
|
||||||
|
|
||||||
|
type User struct {
|
||||||
|
Email string // map key
|
||||||
|
// Profile Profile
|
||||||
|
}
|
||||||
|
|
||||||
|
var users_file = "data/users.json"
|
||||||
|
|
||||||
|
func SaveUsers() {
|
||||||
|
jsonutil.WritePretty(users_file, Users)
|
||||||
|
}
|
||||||
|
func LoadUsers() {
|
||||||
|
err := jsonutil.ReadFile(users_file, &Users)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"dofdev/data"
|
||||||
"dofdev/src/router"
|
"dofdev/src/router"
|
||||||
"dofdev/tem"
|
"dofdev/tem"
|
||||||
)
|
)
|
||||||
|
@ -12,6 +13,9 @@ import (
|
||||||
func init() {
|
func init() {
|
||||||
fmt.Println("init()")
|
fmt.Println("init()")
|
||||||
tem.Load()
|
tem.Load()
|
||||||
|
|
||||||
|
data.LoadUsers()
|
||||||
|
fmt.Println(len(data.Users), "users")
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue