Initial commit

This commit is contained in:
Johannes Rothe 2022-02-06 22:13:36 +01:00
parent 187082e049
commit 5d93697506
5 changed files with 42 additions and 0 deletions

23
cards/deck.go Normal file
View File

@ -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
}

3
cards/go.mod Normal file
View File

@ -0,0 +1,3 @@
module cards
go 1.17

6
cards/main.go Normal file
View File

@ -0,0 +1,6 @@
package main
func main() {
cards := newDeck()
cards.print()
}

3
helloworld/go.mod Normal file
View File

@ -0,0 +1,3 @@
module main
go 1.17

7
helloworld/main.go Normal file
View File

@ -0,0 +1,7 @@
package main
import "fmt"
func main() {
fmt.Println("Hello World!")
}