Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "bufio"
- "fmt"
- "os"
- )
- func main() {
- //s := spinner.New(spinner.CharSets[9], 100*time.Millisecond)
- f, err := os.Open(os.Args[1])
- if err != nil {
- panic(err)
- }
- //start := time.Now()
- //s.Start()
- var lineCount uint64
- //var wordCount uint64
- reader := bufio.NewReader(f)
- for _, err := reader.ReadBytes('\n'); err == nil; _, err = reader.ReadBytes('\n') {
- lineCount++
- //wordCount += uint64(len(bytes.Fields(b)))
- }
- //s.Stop()
- //totalTime := time.Since(start)
- fmt.Printf("The number of lines is: %d\n", lineCount)
- //fmt.Printf("The number of words is: %d\n", wordCount)
- //fmt.Printf("It took me %v to perform this stupid task\n", totalTime)
- f.Close()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement