added upc length limiters and fixed 10 digit bug
This commit is contained in:
		
							
								
								
									
										13
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								main.go
									
									
									
									
									
								
							@@ -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))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user