File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed
Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -61,16 +61,11 @@ func handleLine(input string) {
6161 return
6262}
6363
64- func main () {
65- if len (arguments ) < 2 {
66- fmt .Printf ("Command needs an argument.\n " )
67- os .Exit (1 )
68- }
69- var fileName string = arguments [1 ]
64+ func processFile (fileName string ) int {
7065 file , err := os .Open (fileName )
7166 if err != nil {
7267 fmt .Printf ("Error reading file: %s.\n " , err .Error ())
73- os . Exit ( 1 )
68+ return 1
7469 }
7570
7671 scanner := bufio .NewScanner (file )
@@ -86,7 +81,17 @@ func main() {
8681
8782 file .Close ()
8883 if isErrorDetected == true {
84+ return 1
85+ }
86+ return 0
87+ }
88+
89+ func main () {
90+ if len (arguments ) < 2 {
91+ fmt .Printf ("Command needs an argument.\n " )
8992 os .Exit (1 )
9093 }
91- os .Exit (0 )
94+
95+ var fileName string = arguments [1 ]
96+ os .Exit (processFile (fileName ))
9297}
You can’t perform that action at this time.
0 commit comments