File tree 2 files changed +13
-4
lines changed
2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 6
6
)
7
7
8
8
func StartCar (carName string ) (string , error ) {
9
+
9
10
if carName == "" {
10
11
return "" , errors .New ("there has been some error! Cannot send empty car name" )
11
12
}
Original file line number Diff line number Diff line change @@ -3,15 +3,23 @@ package main
3
3
import (
4
4
"fmt"
5
5
6
+ "log"
7
+
6
8
"aniket-batabyal.com/car"
7
9
)
8
10
9
11
func 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 ("" )
12
18
13
19
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 )
15
23
}
16
- fmt .Println ("The message is: " , message )
24
+ fmt .Println (message )
17
25
}
You can’t perform that action at this time.
0 commit comments