Comments (3)
I saw this recommendation before @amanuel2
Have to say I like it the way todd does it, because it does not hide our error handling. When reading code I can read what we do when an error occurs which often is quite important. Works better with my reading flow also.
In the end it's a matter of style i guess.
from golangtraining.
You wouldn't always want to panic when handling errors. In simple example apps there is no need to recover from a failure, but when you are developing an application that has real-world purpose you would want to handle and recover from errors. So you would recover in the if
statement. If you really want to use the check
function you could maybe modify it like this:
func check(e error, callback func(e error)) {
if e != nil {
callback(e)
}
}
and then handle errors like this:
check(err, func(e error) {
tryAgain()
})
Hope this helps :)
from golangtraining.
Yea @apkrieg you can manupilate it how you want it. But im just asking if you guys want to change it so there isnt a
if e!=nil{
//DoStuff
}
Just make a function so it dosent get repetitive and its good/clean code.
from golangtraining.
Related Issues (20)
- Infinite loop - 22_go-routines/09_channels/00_unbuffered-channels-block
- there is no "text-templates" folder. but in your video there is HOT 1
- I get this error in the example file. HOT 3
- HOW TO USE HTML WITH GO HOT 3
- HOW TO LINK WEBPAGES IN GO
- ADDING CSS FILE IN GO HOT 1
- Downloads but gives error, should mention this in the notes perhaps? HOT 3
- Cannot find list of packages HOT 2
- fmt HOT 2
- Issue in calling a function from DLL in GO Lang
- Potential Security Issue
- Like you ID pic/Fam pic.md HOT 1
- Can we get a README? HOT 1
- Why not add go.mod?
- How to use the REPL mode in the Golang language HOT 2
- Golang help
- how to join golang learn HOT 1
- unable to download course material in GOPATH HOT 1
- Is the project still under maintenance HOT 1
- How to use the REPL mode in the Golang language
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from golangtraining.