8000 GitHub - angadn/DONOTUSE-okgo: OKGO solves the Golang nested-error-checking if-else hell · GitHub
[go: up one dir, main page]

Skip to content
< 8000 div class="d-none">

About

OKGO solves the Golang nested-error-checking if-else hell

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

⛔️ USAGE DISCOURAGED ⛔️

OKGO leads to terribly unreadable code as the tendency to use it everywhere increases dramatically over time.


OKGO

Error checking can become tedious work in Golang, with tons of nested if-blocks, or worse, jumpy goto-like code with return statements that terminate functions prematurely on errors. OKGO is a microlibrary that proposes a funkier solution.

Example Usage

...
var (
    email      Email
    uniqueSpec UniqueEmailSpecification
    request    UserRequest
    err        error
)

okgo.NewOKGO(&err).On(func() error {
    email, err = NewEmail(str)
    return err
}).On(func() error {
    return uniqueSpec.Verify(email)
}).On(func() error {
    return json.NewDecoder(r).Decode(&request)
}).Run()

if err == nil {
    request.Resolve()
} else {
    log.Print(err)
}
...

About

OKGO solves the Golang nested-error-checking if-else hell

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

0