Last active
January 3, 2016 22:19
-
-
Save marawannwh/8527976 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type User struct { | |
Id int64 | |
Name string | |
Email string | |
Username string | |
TablesIds []uint8 | |
HashedPassword []byte | |
Created int64 | |
Updated int64 | |
} | |
func (c Application) getUserByUsername(username string) *models.User { | |
row := c.Txn.QueryRow(`SELECT id, name, email, username, hashedpassword, created, updated, | |
tablesids FROM users where username = $1`, username) | |
if row == nil { | |
return nil | |
} | |
user := models.User{} | |
err := row.Scan(&user.Id, &user.Name, &user.Email, &user.Username, &user.HashedPassword, &user.Created, &user.Updated, &user.TablesIds) | |
log.Println(reflect.TypeOf(user.TablesIds[0]).Kind()) // uint8 | |
log.Println(user.TablesIds[0]) // 123 | |
if err != nil { | |
log.Println(err) | |
return nil | |
} | |
return &user | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment