dust09's recent timeline updates
dust09

dust09

V2EX member #402466, joined on 2019-04-17 10:14:12 +08:00
dust09's recent replies
Apr 23, 2019
Replied to a topic by ht4266394 Linux Linux 做桌面哪个性能稳定些
openSUSE
DoTheThing 函数内 err 不是同一个
````go
package main

import (
"errors"
"fmt"
)

var ErrDidNotWork = errors.New("did not work")

func DoTheThing(reallyDoIt bool) (err error) {
fmt.Println("err:",&err)
if reallyDoIt {
result, err := tryTheThing()
if err != nil || result != "it worked" {
err = ErrDidNotWork
}
fmt.Println("err:",&err)
}
return err
}

func tryTheThing() (string,error) {
return "",ErrDidNotWork
}

func main() {
fmt.Println(DoTheThing(true))
fmt.Println(DoTheThing(false))
}
````
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   888 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 20:38 · PVG 04:38 · LAX 13:38 · JFK 16:38
♥ Do have faith in what you're doing.