MrInvicto

Golang

Learn Golang programming with practical tutorials, best practices, error handling techniques, and advanced Go development concepts.

Posted in Golang on by

Panics are unhandled errors in Golang which are not anticipated while writing code. In order to capture them we need to explicitly added recover statements so that our code can recover from these panics in a graceful way.

Posted in Golang on by

If you have an unique index on a table and try to to insert duplicate records in that table you get a Duplicate key violation error. You can handle this error more gracefully by capturing it. If you are using GORM in Golang, then you can easily check if an error is of type Duplicate Key.