Skip to content
/ eop Public
forked from cn0047/eop

Here you can find 2 approaches how to deal with errors: first one - return error, another one - panic. Which better - it's up to you!

Notifications You must be signed in to change notification settings

taharah/eop

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Error or Panic

CircleCI Go Report Card Codacy Badge Maintainability

Here you can find 2 approaches how to deal with errors: first one - return error, another one - panic.
Which better - it's up to you!

Prerequisites

Common stuff between all approaches - workflow: here you can find one controller which calls service function which works like a facade and performs sign up into:

  • facebook
  • twitter
  • pinterest

you can see it on sequence diagram:

sequence diagram

Main idea

You can go through src/app/examples directory and find implementations for different approaches, you can compare different approaches and decide which one is better for you.
But regarding amount of code it looks like this: e VS p

Usage

To check that all approaches work in same way you can run:

git clone https://github.com/cn007b/eop.git && cd eop
export GOPATH=$PWD

# return error:
go run -race src/app/main.go --strategy=error
go run -race src/app/main.go --strategy=error --username=bond
go run -race src/app/main.go --strategy=error --username=james

# return error from goroutine:
go run -race src/app/main.go --strategy=error_goroutine
go run -race src/app/main.go --strategy=error_goroutine --username=bond
go run -race src/app/main.go --strategy=error_goroutine --username=james

# panic:
go run -race src/app/main.go --strategy=panic
go run -race src/app/main.go --strategy=panic --username=bond
go run -race src/app/main.go --strategy=panic --username=james

# panic in goroutine:
go run -race src/app/main.go --strategy=panic_goroutine
go run -race src/app/main.go --strategy=panic_goroutine --username=bond
go run -race src/app/main.go --strategy=panic_goroutine --username=james

# panic like PRO:
go run -race src/app/main.go --strategy=pro_panic
go run -race src/app/main.go --strategy=pro_panic --username=bond
go run -race src/app/main.go --strategy=pro_panic --username=james

# panic in goroutine like PRO:
go run -race src/app/main.go --strategy=pro_panic_goroutine
go run -race src/app/main.go --strategy=pro_panic_goroutine --username=bond
go run -race src/app/main.go --strategy=pro_panic_goroutine --username=james

About

Here you can find 2 approaches how to deal with errors: first one - return error, another one - panic. Which better - it's up to you!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%