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
 | 
							evenNumber := 0
 | 
				
			||||||
		var remainder int
 | 
							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 {
 | 
							for i, num := range upc {
 | 
				
			||||||
			if i%2 == 0 {
 | 
								if i%2 == 0 {
 | 
				
			||||||
				oddString, err := strconv.Atoi(string(num))
 | 
									oddString, err := strconv.Atoi(string(num))
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user