Compare commits

4 Commits

Author SHA1 Message Date
5f49a09ab4 added zip to gitignore 2025-08-13 09:18:11 -04:00
42ccf3c812 fixed bug where empty line would crash program 2025-08-13 09:14:42 -04:00
2fa6aef836 deleted answer file 2025-05-06 17:03:49 -04:00
25a7658328 fixed bug where real numbers crashed app 2025-05-06 16:52:18 -04:00
4 changed files with 54 additions and 32 deletions

1
.gitignore vendored
View File

@@ -8,6 +8,7 @@
*.dll *.dll
*.so *.so
*.dylib *.dylib
*.zip
# Test binary, built with `go test -c` # Test binary, built with `go test -c`
*.test *.test

View File

@@ -14,6 +14,7 @@ UPC
2.0006670732e+11 2.0006670732e+11
2.0006955667e+11 2.0006955667e+11
2.0007279122e+11 2.0007279122e+11
0075849385857
2.0007279132e+11 2.0007279132e+11
2.0007279138E+11 2.0007279138E+11
2.0007279147E+11 2.0007279147E+11

10
isNumeric.go Normal file
View File

@@ -0,0 +1,10 @@
package main
import (
"regexp"
)
func isNumeric(s string) bool {
match, _ := regexp.MatchString("^[0-9]+$", s)
return match
}

10
main.go
View File

@@ -71,6 +71,7 @@ func main() {
})) }))
for _, upc := range upcs { for _, upc := range upcs {
if len(upc) > 0 {
checkForNonStartingNumber := regex.MatchString(upc) checkForNonStartingNumber := regex.MatchString(upc)
if checkForNonStartingNumber { if checkForNonStartingNumber {
@@ -78,6 +79,11 @@ func main() {
continue continue
} }
if isNumeric(upc) {
gtins = append(gtins, upc)
continue
}
// Lower case the E // Lower case the E
upc = strings.ToLower(upc) upc = strings.ToLower(upc)
// Split scientific notation at the e+ point // Split scientific notation at the e+ point
@@ -106,6 +112,10 @@ func main() {
gtins = append(gtins, upc) gtins = append(gtins, upc)
checkBar.Add(1) checkBar.Add(1)
} else {
gtins = append(gtins, "")
checkBar.Add(1)
}
} }
answerBar := progressbar.NewOptions(len(gtins), answerBar := progressbar.NewOptions(len(gtins),