第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

比較 golang 中的錯誤

比較 golang 中的錯誤

Go
白衣非少年 2021-10-18 14:08:27
我正在用 golang 編寫一個基本的密碼認(rèn)證系統(tǒng)。我使用 bcrypt 對密碼進(jìn)行散列并將散列保存在數(shù)據(jù)庫中。這是從數(shù)據(jù)庫中檢索經(jīng)過身份驗證的帳戶的函數(shù)。func FindAccount(db *gorp.DbMap, email, password string) (*Account, error) {    account, err := FindByEmail(db, email)    if err != nil {        return nil, err    }    if account == nil {        return nil, nil    }    if err := bcrypt.CompareHashAndPassword([]byte(account.HashedPassword), []byte(password)); err != nil {        return nil, err    }    return account, nil}和來電者:account, err := FindAccount(db, email, password)if err != nil {    if err == bcrypt.ErrMismatchedHashAndPassword {        log.Printf("Why doesn't this condition match?")        return nil, EmailPasswordInvalidError{}    }    log.Printf("bcrypt.Err: %p, %#v", bcrypt.ErrMismatchedHashAndPassword, bcrypt.ErrMismatchedHashAndPassword)    log.Printf("err       : %p, %#v", err, err)    return nil, err}當(dāng)我使用此代碼并提供無效的電子郵件和密碼時,會發(fā)生以下情況:sessions.go:51: bcrypt.Err: 0xc2080290b0, &errors.errorString{s:"crypto/bcrypt: hashedPassword is not the hash of the given password"}sessions.go:52: err       : 0xc2080291e0, &errors.errorString{s:"crypto/bcrypt: hashedPassword is not the hash of the given password"}為什么指針地址不同?我們不能只比較錯誤嗎?
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 251 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號