【发布时间】:2019-07-08 13:40:56
【问题描述】:
我正在调用带有错误类型值的方法(代码示例中的 foo())。我不在乎这个结果。什么是正确的代码风格编写方式? Errcheck linter 让我检查这个错误。
//for example, same method may be called from imported entity
func foo() error {
if err := someFunction(); err != nil {
return err
}
return nil
}
func process() {
//linter doesn't like this
foo()
//this way leads to unused variable error
err := foo()
//is this clean way?
_ = foo()
return
}
【问题讨论】: