lburgazzoli commented on pull request #2766:
URL: https://github.com/apache/camel-k/pull/2766#issuecomment-976247107


   > @lburgazzoli the closure pattern looks good.
   > 
   > To be honest, even the "plain procedural" approach looks good to me:
   > 
   
   I do agree on this point and I originally opted to use it, however there is 
a subtle issue in this block: 
   
   ```go
   if err = io.WriteString(f, "hello world"); err != nil {
       f.Close()
       return err
   }
   ```
   
   Is it correct to swallow any error that may be detected while closing the 
file ?  In my case I experimented with the `multierr` package to combine 
multiple errors but that's also something that I'm not sure about.
   
   I guess here what we need to find is the logical pattern we want to use to 
deal with this case and enforce with gosec/lint and  when doing PR review 
rather than the specific coding patter (like the closure I introduced as 
exploration).
   
   > 
   > Sometimes, no-pattern is the best pattern, and I find it a bit ironic the 
hype with `defer` biased use to use it brokenly, in contradiction with the 
general Golang philosophy, that aims for minimalism and robustness, like with 
error handling for example.
   
   100% agree
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to