From 5d93697506fd287934e07ebe1443dd7736530d02 Mon Sep 17 00:00:00 2001 From: Johannes Rothe Date: Sun, 6 Feb 2022 22:13:36 +0100 Subject: [PATCH] Initial commit --- cards/deck.go | 23 +++++++++++++++++++++++ cards/go.mod | 3 +++ cards/main.go | 6 ++++++ helloworld/go.mod | 3 +++ helloworld/main.go | 7 +++++++ 5 files changed, 42 insertions(+) create mode 100644 cards/deck.go create mode 100644 cards/go.mod create mode 100644 cards/main.go create mode 100644 helloworld/go.mod create mode 100644 helloworld/main.go diff --git a/cards/deck.go b/cards/deck.go new file mode 100644 index 0000000..5a12dbe --- /dev/null +++ b/cards/deck.go @@ -0,0 +1,23 @@ +package main + +import "fmt" + +type deck []string + +func (d deck) print() { + for i, card := range d { + fmt.Println(i, card) + } +} + +func newDeck() deck { + cards := deck{} + cardSuits := []string{"Spades", "Diamonds", "Hearts", "Clubs"} + cardValues := []string{"Ace", "Two", "Three", "Four"} + for _, suite := range cardSuits { + for _, value := range cardValues { + cards = append(cards, value+" of "+suite) + } + } + return cards +} diff --git a/cards/go.mod b/cards/go.mod new file mode 100644 index 0000000..1a2c165 --- /dev/null +++ b/cards/go.mod @@ -0,0 +1,3 @@ +module cards + +go 1.17 diff --git a/cards/main.go b/cards/main.go new file mode 100644 index 0000000..86602e4 --- /dev/null +++ b/cards/main.go @@ -0,0 +1,6 @@ +package main + +func main() { + cards := newDeck() + cards.print() +} diff --git a/helloworld/go.mod b/helloworld/go.mod new file mode 100644 index 0000000..c0ecf8b --- /dev/null +++ b/helloworld/go.mod @@ -0,0 +1,3 @@ +module main + +go 1.17 diff --git a/helloworld/main.go b/helloworld/main.go new file mode 100644 index 0000000..b1b14d0 --- /dev/null +++ b/helloworld/main.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("Hello World!") +}