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()) ti, err := ParseTileIndex(path.Join("test_data", "world1", "tiles.txt")) if err != nil { fmt.Println("Err:", err) return } fmt.Printf("Loaded %d tiles from 'world1'\r\n", len(ti.Tiles)-1) for i, t := range ti.Tiles { if i == 0 { continue } fmt.Printf("Id=%d Symbol='%s' Color='%s'\r\n", i, t.Symbol, t.Color) } w, err := LoadWorld(path.Join("test_data", "world1")) if err != nil { fmt.Println("Err:", err) return } fmt.Println("Loaded", w.Name, "a", w.Width, "x", w.Height) }