Golang面试题解析(三)

梦朝思夕 ·
27题如果改为下面的写法的话,执行的结果是: did not work <nil> func DoTheThing(reallyDoIt bool) (err error) { if reallyDoIt { var result string result, err = tryTheThing() if err != nil || result != "it worked" { err = ErrDidNotWork } } return err }
#1