agreed, within the std lib, or any package to be consumed, panic is not 
right.

In the case i m dealing with now, 
web application controller, 
with resources that it is not interesting to retry (db, fs , session),
it does look like to me there s not much to do except
1- log
2- die
3- recover to print a gone south message

the logic for 1 & 2 is heavily cluttering the code
when within the same 50 lines the program has to
begin a transaction
read db,
write db
commit the db
write a file
save session
+ additional logic to make the program actually useful to human

In the suggestion i made 1 a 2 can be 
embedded, 
behaviored,
parametrized, 
and un-clutter the code with a one liner.

Sometimes MustFunc does not seem so good,
there are func that can fail fatal, but that are used only once (database 
data provider?),
should we add a MustFunc, that means clutter that func parameters, 
or instance of provider with an additional logging logic to be duplicated 
as many times as a MustFunc should exist.

About the logging case, i m not sure i got you right, 
i suspect a lack of creativity.


On Friday, November 25, 2016 at 10:08:37 PM UTC+1, Volker Dobler wrote:
>
> Am Freitag, 25. November 2016 15:49:00 UTC+1 schrieb mhh...@gmail.com:
>>
>> Does it make any sense to you too ?
>>
>
> No. Sorry.
>
> For the rare cases where a panic is appropriate you can easily
> provide Must... functions (see package template or regexp).
> For other cases panicking is not appropriate.
>
> For the logging case: Please no. This is just ignoring the error
> in disguise. And it often wouldn't work out: Lots of functions have
> no sensible return on error, e.g. http.Get requires different control
> flow depending on err being nil or not.
>
> All such ideas have been discussed and are not better then
> the status quo.
>
> V.
>
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to