Better HN
topnewbestaskshowjobs
Log inSign up

drakedrepar

3 karma · joined Sep 2, 2021 (5y ago) · 4 submissions

Submissions

comment 1w ago · link · parent

The article is paywalled

comment 7mo ago · link · parent

The article is paywalled

comment 2y ago · link · parent

Could you provide a link to full article without the hoops and paywalls?

comment 5y ago · link · parent

I understand the criticism from the author, but he missed a simple case to make the flow a bit better when a function returns a value and an error:

From the article:

if val, err := bar(); err != nil { // ERROR: val declared but not used return err } fmt.Println(val) // ERROR: undeclared name: val

If you want to use the val after the if, you could use it in an else:

if val, err := bar(); err != nil { // ERROR: val declared but not used return err } else { fmt.Println(val) // this is ok }