https://github.com/alexpantyukhin/go-try-catch
try-catch block for Go
https://github.com/alexpantyukhin/go-try-catch
go golang try try-catch
Last synced: about 1 year ago
JSON representation
try-catch block for Go
- Host: GitHub
- URL: https://github.com/alexpantyukhin/go-try-catch
- Owner: alexpantyukhin
- Created: 2019-04-23T09:57:05.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-24T20:08:29.000Z (about 7 years ago)
- Last Synced: 2025-01-26T00:11:24.284Z (over 1 year ago)
- Topics: go, golang, try, try-catch
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Go try-catch
[](https://travis-ci.org/alexpantyukhin/go-try-catch)
[](https://godoc.org/github.com/alexpantyukhin/go-try-catch)
# Motivation
ALL LANGUAGES SHOULD LOOK LIKE C#))) If you are still there then.. don't worry it's a joke) But many a true word is spoken in jest. This repository was made for fun. I don't want to get some lib which will be used in some real systems making this project. My advise: DON'T USE IT IN REAL PROJECTS :).
# Usages
It's possible to try use try-catch:
```go
Try(func() {
fmt.Println("Hello Try! Let's get some fun!")
RaiseError(&Error{"Oh no! something went wrong! Let's get out of here!!!"})
}).
Catch(func(err *Error) {
fmt.Println("Hehe... So good we have Catch there.")
}).
Finally(func(){
fmt.Println("Roll up, time to go home.")
}).
Do()
```
# Installation
Just `go get` this repository with the following way:
```
go get github.com/alexpantyukhin/go-try-catch
```