I think the more idiomatic way would be

if err!=nil {
   goto return_defaults
}

This is pretty standard for multiple values. It also allows earlier checks to alter some of the defaults if they are declared as local variables.

-----Original Message-----
From: Tong Sun
Sent: Jul 22, 2019 1:51 PM
To: golang-nuts
Subject: [go-nuts] Preparing defaults for multiple-values-returning functions

I want to define a default set of values for the multiple-values-returning function, so when doing error checking along the way, I can return such default set when things go wrong.

How can I do that? 
Is it possible to make the 17&18 line of the following working?
https://play.golang.org/p/OX6QwWXc2ch

thx

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/b74868fc-65a0-4b04-a898-411139b3b9f8%40googlegroups.com.




-- 
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/679215438.9486.1563821850024%40wamui-eagle.atl.sa.earthlink.net.

Reply via email to