loading...

re: Simple Idea for Improving Error Handling of Go VIEW POST

FULL DISCUSSION
 

I love panic

Because it can stop the immediately,
But this not is golang suggested practices :(

func ThrowIfError(err error) {
    if err != nil {
        panic(err)
    }
}


_, err = fd.Write(p0[a:b])
ThrowIfError(err)

_, err = fd.Write(p0[c:d])
ThrowIfError(err)

_, err = fd.Write(p0[e:f])
ThrowIfError(err)

It look like a block, easy to copy
(I love DRY, but golang hard to do it)

Code of Conduct Report abuse