Hello.
You can achieve this by using a named return value and overwriting it in a
deferred function, like so: https://play.golang.org/p/4HvVQ6N-I9
Note that the value returned by recover() is not guaranteed to be an error.
In my toy example, I work around this fact by passing it to fmt.Errorf i
Hello,
Try this:
func MustNotPanic() (err error) {
defer func(){
err=recover()
}()
PanicFunction()
}
--
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, se
Hi,
I would like to shield my application from any possible panicking by the
third-party library. There was an occasion when a third party library
crashed my application due to unnecessary panicking. I am thinking
of creating a thin wrapper that will also catch any panic into error. How
can I
Filed: https://github.com/golang/go/issues/19687
On Thu, Mar 23, 2017 at 4:41 PM, 'Keith Randall' via golang-nuts
wrote:
>
>
> On Thursday, March 23, 2017 at 4:24:40 PM UTC-7, Caleb Spare wrote:
>>
>> That's very good to know. Thanks, Ian.
>>
>> Unfortunately if I use this KeepAlive-based fix, p
On Thursday, March 23, 2017 at 4:24:40 PM UTC-7, Caleb Spare wrote:
>
> That's very good to know. Thanks, Ian.
>
> Unfortunately if I use this KeepAlive-based fix, p escapes and so the
> function now allocates. I guess I'll stick with the original version
> from my first email.
>
> Does this
That's very good to know. Thanks, Ian.
Unfortunately if I use this KeepAlive-based fix, p escapes and so the
function now allocates. I guess I'll stick with the original version
from my first email.
Does this indicate a shortcoming of either compiler support for
KeepAlive or escape analysis in ge
On Thu, Mar 23, 2017 at 11:56 AM, Peter Kleiweg wrote:
> Op donderdag 23 maart 2017 17:46:18 UTC+1 schreef Ian Lance Taylor:
>>
>> On Thu, Mar 23, 2017 at 8:54 AM, Peter Kleiweg wrote:
>> > Some code that includes C code compiles fine on Linux, but gives strange
>> > errors on Darwin.
>> >
>> >
>
Op donderdag 23 maart 2017 17:46:18 UTC+1 schreef Ian Lance Taylor:
>
> On Thu, Mar 23, 2017 at 8:54 AM, Peter Kleiweg > wrote:
> > Some code that includes C code compiles fine on Linux, but gives strange
> > errors on Darwin.
> >
> >
> > In one source file, that doesn't include C, I have thi
On Thu, Mar 23, 2017 at 9:16 AM, Caleb Spare wrote:
>
> Brief follow-up: does the seeming validity of the code rely at all on
> the fact that the indicated line is written as a single line? What if,
> instead, a *StringHeader var were extracted?
>
> func stringToSliceUnsafe(s string) []uint64 {
>
On Thu, Mar 23, 2017 at 8:54 AM, Peter Kleiweg wrote:
> Some code that includes C code compiles fine on Linux, but gives strange
> errors on Darwin.
>
>
> In one source file, that doesn't include C, I have this:
>
> type reactor_socket struct {
> e State
> f func(State)
Thanks Ian, that's very helpful.
Brief follow-up: does the seeming validity of the code rely at all on
the fact that the indicated line is written as a single line? What if,
instead, a *StringHeader var were extracted?
func stringToSliceUnsafe(s string) []uint64 {
var v []uint64
h
Some code that includes C code compiles fine on Linux, but gives strange
errors on Darwin.
In one source file, that doesn't include C, I have this:
type reactor_socket struct {
e State
Quite agree.
code generation will be especially helpful if it is not something trivial,
and you need several rounds to make it perfect.
@hui zhang,
If you need something generic, take a look
at https://github.com/go-easygen/easygen,
For e.g., here is how I generate the command line CLI ha
13 matches
Mail list logo