go - Whats the correct golang way to do this: -


It seems a bit stupid, definitely a better way?

  err = SendMessageAndWait DB, "This is an exam") If mistake! = Zero {fmt.Println ("Error sending message", mistake) returns} err = DoSomething (DB, "this is an exam") If mistake! = Zero {FMT. Error = SendMessageAndWait (db), "This is a third test") If mistake! = Errl = (any exam is "), if mistake! = Zero {fmt.Println (" error in sending message ", err) Zero {fmt.Println ("Error sending message", error) Returns} ... x10 ...    

Sadly, this is in go, but in a way you can make it cleaner:

  func isError (mistake error, pre string) error {if Mistake! = Zero} log. Printers ("% v:% v", formerly, fault)} returned Error} func check some () error (error), error (pre-string) {B Errul} {Err! = Nil {log.Printf ("% v:% v", prior, err) b = true} {Return noil} func main (if error: = is error (check some (), "some fail"); Err! = Nil {return / * err * /} // If you do not want to return error, So just check it and die if Errbool (check some (), "some more unsuccessful") {return}}    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -