diff --git a/grade-tracker/Makefile b/grade-tracker/Makefile new file mode 100755 index 0000000..d8b97ca --- /dev/null +++ b/grade-tracker/Makefile @@ -0,0 +1,30 @@ +BIN_DIR = ./builds/ +BIN_NAME = grade-tracker +SRC = grade-tracker.go + +all: linux-amd64 linux-arm64 windows-amd64 windows-arm64 mac-amd64 mac-arm64 + +linux: linux-amd64 linux-arm64 + +windows: windows-amd64 windows-arm64 + +mac: mac-amd64 mac-arm64 + +linux-amd64: + env GOOS=linux GOARCH=amd64 go build -o $(BIN_DIR)$(BIN_NAME)-linux-amd64 $(SRC) + +linux-arm64: + env GOOS=linux GOARCH=arm64 go build -o $(BIN_DIR)$(BIN_NAME)-linux-arm64 $(SRC) + +windows-amd64: + env GOOS=windows GOARCH=amd64 go build -o $(BIN_DIR)$(BIN_NAME)-win-amd64.exe $(SRC) + +windows-arm64: + env GOOS=windows GOARCH=arm64 go build -o $(BIN_DIR)$(BIN_NAME)-win-arm64.exe $(SRC) + +mac-amd64: + env GOOS=darwin GOARCH=amd64 go build -o $(BIN_DIR)$(BIN_NAME)-mac-amd64 $(SRC) + +mac-arm64: + env GOOS=darwin GOARCH=arm64 go build -o $(BIN_DIR)$(BIN_NAME)-mac-arm64 $(SRC) + diff --git a/grade-tracker/build-all.sh b/grade-tracker/build-all.sh deleted file mode 100755 index 347d558..0000000 --- a/grade-tracker/build-all.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -# linux -env GOOS=linux GOARCH=amd64 go build -o builds/tracker-linux-amd64 tracker.go -env GOOS=linux GOARCH=arm64 go build -o builds/tracker-linux-arm64 tracker.go - -# windows -env GOOS=windows GOARCH=amd64 go build -o builds/tracker-win-amd64.exe tracker.go -env GOOS=windows GOARCH=arm64 go build -o builds/tracker-win-arm64.exe tracker.go - - -env GOOS=darwin GOARCH=amd64 go build -o builds/tracker-mac-amd64 tracker.go -env GOOS=darwin GOARCH=arm64 go build -o builds/tracker-mac-arm64 tracker.go diff --git a/grade-tracker/tracker.go b/grade-tracker/grade-tracker.go similarity index 91% rename from grade-tracker/tracker.go rename to grade-tracker/grade-tracker.go index 1e28c0f..3393357 100644 --- a/grade-tracker/tracker.go +++ b/grade-tracker/grade-tracker.go @@ -14,7 +14,7 @@ func usage(msg string) { fmt.Println(" ", os.Args[0], " ") } -func check(e error) { +func checkError(e error) { if e != nil { fmt.Println(e) os.Exit(1) @@ -28,8 +28,13 @@ func main() { } file, err := os.Open(os.Args[1]) - check(err) - defer file.Close() + checkError(err) + defer func(file *os.File) { + err := file.Close() + if err != nil { + fmt.Println(err) + } + }(file) fmt.Println("Starting report for", os.Args[1]) fmt.Println("========================================================") @@ -64,13 +69,13 @@ func main() { name := strings.TrimSpace(fields[0]) achieved, err := strconv.ParseFloat(strings.TrimSpace(fields[1]), 32) - check(err) + checkError(err) possible, err := strconv.ParseFloat(strings.TrimSpace(fields[2]), 32) - check(err) + checkError(err) final, err := strconv.ParseFloat(strings.TrimSpace(fields[3]), 32) - check(err) + checkError(err) if achieved > possible { fmt.Println("Achieved is greater than possible for", name)