go-super

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2023 License: MIT

README

Go Report Card Maintainability


go-super

Making Go more convenient

github.com/sarumaj/go-super/errors


package main

import (
  "fmt"
  "os"

  supererrors "github.com/sarumaj/go-super/errors"
)

func main() {
  // Register callback for error
  supererrors.RegisterCallback(func(err error) {
    _, _ = fmt.Fprintln(os.Stderr, err)
  })

  // returns *os.File directly and calls callback only if error occures
  file := supererrors.ExceptFn(supererrors.W(os.Create("file.txt")))

  // try to close file and call callback on error which is not os.ErrClosed
  defer supererrors.Except(file.Close(), os.ErrClosed)
}  

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL