added upc length limiters and fixed 10 digit bug

This commit is contained in:
John O'Keefe 2023-12-08 09:54:35 -05:00
parent 9321f187d2
commit 80bcb32d4c

13
main.go
View File

@ -48,6 +48,19 @@ func main() {
evenNumber := 0
var remainder int
if upcLength < 10 {
gtins = append(gtins, "Cannot process upcs less than 10 digits")
continue
}
if upcLength == 10 {
upc = "0" + upc
}
if upcLength > 13 {
gtins = append(gtins, "GTINs longer than 14 digits are not valid")
}
for i, num := range upc {
if i%2 == 0 {
oddString, err := strconv.Atoi(string(num))