kdocs
GitHub
Lang - Runtime
Lang - Runtime
  • Go
    • Modules & Packages
    • Variables
    • Structs
    • Interfaces
    • Functions
    • Control Structures
    • Erro Handling
    • Concurrency
    • Testing
    • Fuzzing
  • Web
    • V8 Engine
    • Node.js
      • New Project
    • Deno
      • New Project
Powered by GitBook
On this page
  • About
  • Exit with panic
  1. Go

Erro Handling

About

In Go, error handling works a bit differently. You should write your functions in a way that errors should not crash the application.

func convert() (float64, error) {
    if a == '' {
        return nil, errors.New("It failed")
    }
    return 10, nil
}

Exit with panic

You can exit the program ungracefully with panic().

a, err = convert()
if err != nil {
    panic(err)
}
PreviousControl StructuresNextConcurrency

Last updated 1 month ago