handled words in files
This commit is contained in:
parent
f973ce2c45
commit
5a0aa7bcdb
11
main.go
11
main.go
@ -4,6 +4,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -41,6 +42,9 @@ func main() {
|
|||||||
|
|
||||||
var gtins []string
|
var gtins []string
|
||||||
|
|
||||||
|
regex, err := regexp.Compile("[^0-9]")
|
||||||
|
Error(err)
|
||||||
|
|
||||||
for _, upc := range upcs {
|
for _, upc := range upcs {
|
||||||
|
|
||||||
upcLength := len(upc)
|
upcLength := len(upc)
|
||||||
@ -57,6 +61,13 @@ func main() {
|
|||||||
evenNumber := 0
|
evenNumber := 0
|
||||||
var remainder int
|
var remainder int
|
||||||
|
|
||||||
|
checkForNonNumber := regex.MatchString(upc)
|
||||||
|
|
||||||
|
if checkForNonNumber {
|
||||||
|
gtins = append(gtins, upc)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if upcLength < 8 {
|
if upcLength < 8 {
|
||||||
gtins = append(gtins, "Cannot process upcs less than 8 digits")
|
gtins = append(gtins, "Cannot process upcs less than 8 digits")
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user