Handling panic in go

panic: TypeInfo already exists for exported.Account

goroutine 1 [running]:

/home/arun/go/src/github.com/blockkungpao/fbc/app.go:313 +0x115

main.main()
/home/arun/go/src/github.com/blockkungpao/fbc/cmd/fbd/main.go:79 +0x2d
strong text
how to handle these unexpected behaviour?

2 Likes

The best way were to not let it happen at all.

Write your code in a way that panics don’t occur…

Though you can use defer and recover to “catch” a panic. Wont give you much when you do it in main though, as it will exit anyway (at the point when the defered function is called, then main is already left…

You can not just restart your program or continue after the try/catch block as you would in many other languages.

2 Likes

how can I know what is the error(in which file it is) and how to remove it.

2 Likes

Learn how to read the trace.

From what you have posted, I’d take a look at line 313 of github.com/blockkungpao/fbc/app.go. Its not available (publicly) on GitHub though…

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.