Amen Tom..  hard to believe that those who determine what Go syntax is, and 
is not, have yet to alter this uniquely awkward feature of the Go 
language.  

On Sunday, June 14, 2020 at 11:26:08 AM UTC-4, Tom Limoncelli wrote:
>
> On Thu, Jun 4, 2020 at 3:34 PM Ian Lance Taylor <ia...@golang.org 
> <javascript:>> wrote: 
> > 
> > On Thu, Jun 4, 2020 at 8:43 AM <lgo...@gmail.com <javascript:>> wrote: 
> > > 
> > > ?? Why not a cleaner syntax e.g.  x = some_func ()  #{ }   .. symbol # 
> arbitrarily chosen 
> > 
> > Besides what other people have said, it may be of interest to glance 
> > through 
> https://github.com/golang/go/issues?q=is%3Aissue+label%3Aerror-handling 
>
> I assert that 80% of the annoyance that people feel is the number of 
> lines required to handle errors, not the syntax.  Thus, a large 
> segment of the community would stop caring about this if we modified 
> gofmt, not the go language.  Specifically, gofmt would simply format 
> short if's on one lie when possible. 
>
> OLD: 
>
> a, err := ioutil.ReadFile(patha) 
> if err != nil { 
>       return err 
> } 
> b, err := ioutil.ReadFile(pathb) 
> if err != nil { 
>       return err 
> } 
> c, err := ioutil.ReadFile(pathc) 
> if err != nil { 
>       return fmt.Errorf("wrapped %v: %w", pathc, err) 
> } 
>
> NEW: 
>
>   a, err := ioutil.ReadFile(patha) 
>   if err != nil { return err } 
>   b, err := ioutil.ReadFile(pathb) 
>   if err != nil { return err } 
>   c, err := ioutil.ReadFile(pathc) 
>   if err != nil { return fmt.Errorf("wrapped %v: %w", pathc, err) } 
>
> This is half as many lines, thus makes it easier to fit on one 
> screenful of an editor, which is often a cognitive limit for a 
> developer. 
>
> I'm not saying that this solves the problem, but I bet it would reduce 
> the pressure to fix it. 
>
> Tom 
>
> -- 
> Email: t...@whatexit.org <javascript:>    Work: 
> tlimonce...@stackoverflow.com 
> Blog:  http://EverythingSysadmin.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/f3ee217c-3df2-4a29-bb62-7ad7337598beo%40googlegroups.com.

Reply via email to