Skip to content

Instantly share code, notes, and snippets.

@6LYTH3
Created June 10, 2011 04:28
Show Gist options
  • Save 6LYTH3/1018231 to your computer and use it in GitHub Desktop.
Save 6LYTH3/1018231 to your computer and use it in GitHub Desktop.
line count use bufio
package main
import (
"fmt"
"os"
"bufio"
)
func main() {
lCount := 0
fb, _ := os.Open(os.Args[1])
buf := bufio.NewReader(fb)
for {
_, _, er := buf.ReadLine()
if er != nil {
break
} else {
lCount++
}
}
fmt.Println(lCount)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment