Giter Site home page Giter Site logo

eop's Introduction

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

eop's People

Contributors

cn007b avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.