Can't get information from Database

Hello!
I hope that you can help me

first file

func (b *Auth) GetInfo(login string) {
	var auth models.Auth

	if strings.Contains(login, "@") {
		auth = db.GetDb().
			Table("profile").
			Select("id, cell_phone, email").
			Where("email = ?", login).
			First(&b)

		return auth

	} else {
		auth = db.GetDb().
			Table("profile").
			Select("id, cell_phone, email").
			Where("phone = ?", login).
			First(&b)

		return auth
	}
}

second file

type Auth struct {
	ID               int    `json:"id"`
	ExtID            string `json:"ext_id"`
	CellPhone        string `json:"cell_phone"`
	Email            string `json:"email"`
}

func Authentication(ctx *gin.Context) {

	login := ctx.Query("login")

	authentication := models.Auth{}
	authentication.GetDriverInfo(login)
	ctx.JSON(http.StatusOK, authentication)

}

third file

func main() {
	db.Initialize()
	router := gin.Default()
core := router.Group("/api/private")
	{
		core.GET("/profile", info.Authentication)
	}
}

I receive response body with empty field
create table + insert i won’t show
What i need to change?

What is getdriverinfo? If this is just a typo and you actually mean get info, then you should use it’s return value instead of omitting it. Or change the b in the method instead of creating a new Auth struct.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.