Initial commit
This commit is contained in:
parent
187082e049
commit
5d93697506
23
cards/deck.go
Normal file
23
cards/deck.go
Normal 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
3
cards/go.mod
Normal file
@ -0,0 +1,3 @@
|
||||
module cards
|
||||
|
||||
go 1.17
|
6
cards/main.go
Normal file
6
cards/main.go
Normal file
@ -0,0 +1,6 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
cards := newDeck()
|
||||
cards.print()
|
||||
}
|
3
helloworld/go.mod
Normal file
3
helloworld/go.mod
Normal file
@ -0,0 +1,3 @@
|
||||
module main
|
||||
|
||||
go 1.17
|
7
helloworld/main.go
Normal file
7
helloworld/main.go
Normal file
@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println("Hello World!")
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user