code: func GetUser(db *sqlx.DB, req *Request) (*User, error) {
  	u := &User{}
  	u.FlexID = req.FlexID
  	u.FlexIDType = req.FlexIDType
  	if req.UserID == 0 {
  		if req.FlexID == "" {
  			return nil, ErrMissingFlexID
  		}
  		switch req.FlexIDType {
  		case FIDTEmail, FIDTPhone, FIDTSession:
  			// Do nothing
  		default:
  			return nil, ErrInvalidFlexIDType
  		}
  		log.Debug("searching for user from", req.FlexID, req.FlexIDType)
  		q := `SELECT userid
  		      FROM userflexids
  		      WHERE flexid=$1 AND flexidtype=$2
  		      ORDER BY createdat DESC`
  		err := db.Get(&req.UserID, q, req.FlexID, req.FlexIDType)
  		if err == sql.ErrNoRows {
  			return u, nil
  		}
  		log.Debug("got uid", req.UserID)
  		if err != nil {
  			return nil, err
  		}
  	}
  	q := `SELECT id, name, email FROM users WHERE id=$1`
  	if err := db.Get(u, q, req.UserID); err != nil {
  		if err == sql.ErrNoRows {
  			return u, nil
  		}
  		return nil, err
  	}
  	return u, nil
  }
docs: // GetUser from an HTTP request.