Skip to content

Commit

Permalink
gofmt 001
Browse files Browse the repository at this point in the history
  • Loading branch information
piperwolters authored Jun 21, 2019
1 parent d341e5a commit 3f4f15c
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions exercise-001-corpus/001/word_count.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,11 @@ import (
"strings"
)

func check(e error) {
if e != nil {
panic(e)
}
}


// scanWords scans the file to parse the strings
func scanWords(path string) []string {
file, err := os.Open(path)
if err != nil {
return nil
panic(err)
}

defer file.Close()
Expand All @@ -42,11 +36,10 @@ func scanWords(path string) []string {
}
words = append(words, word)
}

return words
}


// sortWords is the logic to reverse sort the words according to frequencies
func sortWords(words []string, m map[string]int) {
for _, word := range words {
m[strings.ToLower(word)] += 1
Expand Down Expand Up @@ -75,7 +68,7 @@ func sortWords(words []string, m map[string]int) {
}
}


// Main function
func main() {

// Checking for the necessary command line argument
Expand All @@ -93,4 +86,3 @@ func main() {
// Sort the words by frequencies
sortWords(words, m)
}

0 comments on commit 3f4f15c

Please sign in to comment.