package main import ( "fmt" "path" ) func main() { // The UserDB would be run on the server // But since most/100% of this is examples, we'll setup one up db := &UserDB{} err := db.Open(path.Join("test_data", "test_users.db3")) if err != nil { fmt.Println("Err:", err) return } defer db.Close() // Example query dummy, err := db.FindUser("Test Dummy") if err != nil { // Of course, we'd ask the user for their name and a password then use those // But for our Test Dummy let's just make a dumb and simple setup err = db.CreateUser("Test Dummy", "12345") if err != nil { fmt.Println("Err:", err) return } dummy, err = db.FindUser("Test Dummy") if err != nil { fmt.Println("Err:", err) return } } //fmt.Printf("%#v\r\n", dummy) // Example verification process // I'd also want to verify they aren't trying to login in 2+ places at once err = dummy.VerifyPassword("12345") if err != nil { fmt.Println("Wrong password?") } else { fmt.Printf("Yay, %s has logged in\r\n", dummy.Name) } fmt.Printf("%s is at %s\r\n", dummy.Name, dummy.Loc.String()) r := dummy.Loc.Assign(0, 0) if r == nil { fmt.Println("Assign returns nil?") } else { fmt.Printf("Now %s\r\n", r.String()) } err = db.SaveUser(dummy) if err != nil { fmt.Println("Err:", err) return } }