File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 66)
77
88func StartCar (carName string ) (string , error ) {
9+
910 if carName == "" {
1011 return "" , errors .New ("there has been some error! Cannot send empty car name" )
1112 }
Original file line number Diff line number Diff line change @@ -3,15 +3,23 @@ package main
33import (
44 "fmt"
55
6+ "log"
7+
68 "aniket-batabyal.com/car"
79)
810
911func main () {
10- fmt .Println ("Hey I am a driver" )
11- message , error := car .StartCar ("Ford Mustang" )
12+ // This says that set a prefix everytime you land in an error
13+ log .SetPrefix ("######====> " )
14+ // This disables ot
15+ log .SetFlags (0 )
16+
17+ message , error := car .StartCar ("" )
1218
1319 if error != nil {
14- fmt .Println (error )
20+ // this prints the error and exits the application by setting os.Exit(1)
21+ log .Print ("A lot of errors is not good for your health" )
22+ log .Fatal (error )
1523 }
16- fmt .Println ("The message is: " , message )
24+ fmt .Println (message )
1725}
You can’t perform that action at this time.
0 commit comments