now can also read from stdin
This commit is contained in:
		
							parent
							
								
									8a2c4757b9
								
							
						
					
					
						commit
						18d362c926
					
				@ -68,9 +68,16 @@ func main() {
 | 
				
			|||||||
		os.Exit(1)
 | 
							os.Exit(1)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	filename := os.Args[1]
 | 
						filename := os.Args[1]
 | 
				
			||||||
 | 
						var file *os.File
 | 
				
			||||||
	file, _ := os.Open(filename)
 | 
						if filename != "-" {
 | 
				
			||||||
	defer file.Close()
 | 
							file, err := os.Open(filename)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								panic(err)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							defer file.Close()
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							file = os.Stdin
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	scanner := bufio.NewScanner(file)
 | 
						scanner := bufio.NewScanner(file)
 | 
				
			||||||
	lineno := 0
 | 
						lineno := 0
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user