Compare commits

6 Commits

4 changed files with 82 additions and 58 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,32 +14,33 @@ 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
2.0007295014e+11 2.0007295014E+11
2.0007918627e+11 2.0007918627E+11
2.0007934374e+11 2.0007934374E+11
2.0008145164e+11 2.0008145164E+11
2.0008163031e+11 2.0008163031E+11
2.0010695322e+11 2.0010695322E+11
2.0015648868e+11 2.0015648868E+11
2.0015705634e+11 2.0015705634E+11
2.0016809582e+11 2.0016809582E+11
2.0016897944e+11 2.0016897944E+11
2.0017249002e+11 2.0017249002E+11
2.0017733455e+11 2.0017733455E+11
2.001777807e+11 2.001777807E+11
2.0017778823e+11 2.0017778823E+11
3.2758280554e+11 3.2758280554E+11
3.3758288992e+11 3.3758288992E+11
3.5758284014e+11 3.5758284014E+11
3.5758284353e+11 3.5758284353E+11
3.5758285003e+11 3.5758285003E+11
4.7703952221e+11 4.7703952221E+11
4.770395222e+11 4.770395222E+11
4.8200007703e+11 4.8200007703E+11
4.8200007704e+11 4.8200007704E+11
4.8200007709e+11 4.8200007709E+11
6.4758280292e+11 6.4758280292E+11
6.475828047e+11 6.475828047E+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
}

12
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,13 @@ func main() {
continue continue
} }
if isNumeric(upc) {
gtins = append(gtins, upc)
continue
}
// Lower case the E
upc = strings.ToLower(upc)
// Split scientific notation at the e+ point // Split scientific notation at the e+ point
upcArray := strings.Split(upc, "e+") upcArray := strings.Split(upc, "e+")
@@ -104,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),