Skip to content

Why we used channel here instead of string/error type #4

@imyashkale

Description

@imyashkale

I saw this kind of uses at many places. Please help me to understand this

`func (r *repository) RegisterRepository(input *model.EntityUsers) (*model.EntityUsers, string) {

var users model.EntityUsers
db := r.db.Model(&users)
errorCode := make(chan string, 1)

checkUserAccount := db.Debug().Select("*").Where("email = ?", input.Email).Find(&users)

if checkUserAccount.RowsAffected > 0 {
	errorCode <- "REGISTER_CONFLICT_409"
	return &users, <-errorCode
} `

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions