mirror of
https://github.com/Slug-Boi/cocommit.git
synced 2026-05-13 20:55:47 +00:00
refactor: created a check_err func to shorthand error checks in code
This commit is contained in:
@@ -37,10 +37,7 @@ func main() {
|
|||||||
authors := os.Getenv("author_file")
|
authors := os.Getenv("author_file")
|
||||||
|
|
||||||
file, err := os.Open(authors)
|
file, err := os.Open(authors)
|
||||||
if err != nil {
|
check_err(err)
|
||||||
print("File not found")
|
|
||||||
os.Exit(2)
|
|
||||||
}
|
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
scanner := bufio.NewScanner(file)
|
scanner := bufio.NewScanner(file)
|
||||||
@@ -81,9 +78,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := scanner.Err(); err != nil {
|
check_err(scanner.Err())
|
||||||
os.Exit(2)
|
|
||||||
}
|
|
||||||
// Removes the call command for the program
|
// Removes the call command for the program
|
||||||
args := os.Args[1:]
|
args := os.Args[1:]
|
||||||
|
|
||||||
@@ -209,3 +204,10 @@ func NoInput(args []string, users map[string]user) {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func check_err(e error) {
|
||||||
|
if e != nil {
|
||||||
|
fmt.Println(e.Error())
|
||||||
|
os.Exit(2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user