if 语句的多重赋值

可以通过if条件执行多重赋值,如下代码?


func SendEmail(url, email string) (string, error) {


    genUri := buildUri()

    if err := setRedisIdentity(genUri, email); err != nil; genUrl, err := buildActivateUrl(url, genUri);  {

        return "", err

    }  


    return "test", nil


}


LEATH
浏览 217回答 2
2回答

尚方宝剑之说

看起来你想要这样的东西:package mainimport "fmt"func a(int) int { return 7 }func b(int) int { return 42 }func main() {&nbsp; &nbsp; if x, y := a(1), b(2); x > 0 && x < y {&nbsp; &nbsp; &nbsp; &nbsp; fmt.Println("sometimes")&nbsp; &nbsp; }&nbsp; &nbsp; fmt.Println("always")}输出:sometimesalways
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go