Skip to content

Instantly share code, notes, and snippets.

@marawannwh
Last active January 3, 2016 22:19
Show Gist options
  • Save marawannwh/8527976 to your computer and use it in GitHub Desktop.
Save marawannwh/8527976 to your computer and use it in GitHub Desktop.
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