Don’t use panic
It is okay to use panic in certain situations.
data, err := ioutil.ReadFile("hello.txt")
if err != nil {
panic(err)
}
Wrap an error
func Open(path string) (*DB, error) {
db, err := bolt.Open(path, 0600, &bolt.Options{Timeout: 1 * time.Second})
if err != nil {
return nil, fmt.Errorf("opening bolt db: %w", err)
}
return &DB{db}, nil
}