Created
January 28, 2017 07:49
-
-
Save cipepser/25538f623bc1425da5da9507b34823a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"bufio" | |
"io" | |
"log" | |
"strconv" | |
) | |
func main() { | |
rfp, err := os.Open(os.Args[1]) | |
if err != nil { | |
log.Fatal(err) | |
} | |
defer rfp.Close() | |
N, err := strconv.Atoi(os.Args[2]) | |
if err != nil { | |
log.Fatal(err) | |
} | |
reader := bufio.NewReaderSize(rfp, 4096) | |
var count int | |
for count < N { | |
p, _, err := reader.ReadLine() | |
count++ | |
if err == io.EOF { | |
break | |
} | |
fmt.Println(string(p)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment