handled words in files

This commit is contained in:
John O'Keefe 2023-12-08 19:41:08 -05:00
parent f973ce2c45
commit 5a0aa7bcdb

11
main.go
View File

@ -4,6 +4,7 @@ import (
"bufio"
"fmt"
"os"
"regexp"
"strconv"
"strings"
@ -41,6 +42,9 @@ func main() {
var gtins []string
regex, err := regexp.Compile("[^0-9]")
Error(err)
for _, upc := range upcs {
upcLength := len(upc)
@ -57,6 +61,13 @@ func main() {
evenNumber := 0
var remainder int
checkForNonNumber := regex.MatchString(upc)
if checkForNonNumber {
gtins = append(gtins, upc)
continue
}
if upcLength < 8 {
gtins = append(gtins, "Cannot process upcs less than 8 digits")
continue