package main import ( "fmt" "io/ioutil" "strings" ) // Create a new type of 'deck // which is a slice of string type deck []string func newDeck() deck { cards := deck{} cardSuits := []string{"Spades", "Hearts", "Diamonds", "Clubs"} cardValues := []string{"Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"} for _, suit := range cardSuits { for _, value := range cardValues { cards = append(cards, value+" of "+suit) } } return cards } func (d deck) print() { for _, card := range d { fmt.Println(card) } } func deal(d deck, handsize int) (deck, deck) { return d[:handsize], d[handsize:] } func (d deck) toString() string { return strings.Join([]string(d), ",") } func (d deck) saveToFile(fileName string) error { error := ioutil.WriteFile(fileName, []byte(d.toString()), 0644) return error }