Advertisement
Guest User

gwc

a guest
Mar 18th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.71 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "bufio"
  5.     "fmt"
  6.     "os"
  7. )
  8.  
  9. func main() {
  10.     //s := spinner.New(spinner.CharSets[9], 100*time.Millisecond)
  11.     f, err := os.Open(os.Args[1])
  12.     if err != nil {
  13.         panic(err)
  14.     }
  15.     //start := time.Now()
  16.     //s.Start()
  17.     var lineCount uint64
  18.     //var wordCount uint64
  19.     reader := bufio.NewReader(f)
  20.     for _, err := reader.ReadBytes('\n'); err == nil; _, err = reader.ReadBytes('\n') {
  21.         lineCount++
  22.         //wordCount += uint64(len(bytes.Fields(b)))
  23.     }
  24.     //s.Stop()
  25.     //totalTime := time.Since(start)
  26.     fmt.Printf("The number of lines is: %d\n", lineCount)
  27.     //fmt.Printf("The number of words is: %d\n", wordCount)
  28.     //fmt.Printf("It took me %v to perform this stupid task\n", totalTime)
  29.     f.Close()
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement