added count Votes to playground
This commit is contained in:
parent
b2579520b9
commit
276d8b42d3
19
playground/countVotes.go
Normal file
19
playground/countVotes.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// from Chapter 7 of Head First Go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"git.linuxhg.com/john-okeefe/datafile"
|
||||||
|
"git.linuxhg.com/john-okeefe/keyboard"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func countVotes() {
|
||||||
|
fmt.Printf("What is the name of the file: ")
|
||||||
|
fileString, err := keyboard.GetString()
|
||||||
|
Error(err)
|
||||||
|
fileString = strings.TrimSpace(fileString)
|
||||||
|
lines, err := datafile.GetStrings(fileString)
|
||||||
|
Error(err)
|
||||||
|
fmt.Println(lines)
|
||||||
|
}
|
@ -38,6 +38,8 @@ func main() {
|
|||||||
slices()
|
slices()
|
||||||
case "Variadic Functions":
|
case "Variadic Functions":
|
||||||
variadic()
|
variadic()
|
||||||
|
case "Count Votes":
|
||||||
|
countVotes()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@ -55,6 +57,7 @@ func main() {
|
|||||||
menu.Option("Get the Average Variadic", nil, false, nil)
|
menu.Option("Get the Average Variadic", nil, false, nil)
|
||||||
menu.Option("Slices", nil, false, nil)
|
menu.Option("Slices", nil, false, nil)
|
||||||
menu.Option("Variadic Functions", nil, false, nil)
|
menu.Option("Variadic Functions", nil, false, nil)
|
||||||
|
menu.Option("Count Votes", nil, false, nil)
|
||||||
err := menu.Run()
|
err := menu.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user