Skip to content

elgs/optional

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

optional

If you think if err != nil is too much, this might be for you.

Old way

func New() (string, error) {
	return "Hello", nil
}

data, err := New()
if err == nil {
  log.Fatal(err)
}
log.Println(data)

New way

import "github.com/elgs/optional"

func NewOpt() *optional.Optional[string] {
	return optional.New("Hello", nil)
}

dataOpt := NewOpt()
dataOpt.FatalIfError()
log.Println(dataOpt.Data)

About

If you think if err != nil is too much, this might be for you.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages