Exemplo n.º 1
0
func genUserName(email string, dbh *db.Dbh) string {
	name := strings.Split(email, "@")[0]

	var u models.User
	u = dbh.GetUserByUserName(name)
	if u.Id != 0 {
		var i = 0
		var tmp_name string
		for {
			i++
			tmp_name = strings.Join([]string{name, strconv.Itoa(i)}, "")
			u = dbh.GetUserByUserName(tmp_name)
			if u.Id == 0 {
				return tmp_name
			}
		}
	}
	return name
}