8000 GitHub - frasza/go-cards: Cards
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

frasza/go-cards

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Card

Cards is Go package for creating, shuffling, dealing and saving decks of cards.

Why?

I don't know. Just learning Go :)

Import

First get and import cards package

go get "github.com/frasza/cards"

followed by

import "github.com/frasza/cards"

Example usage

First new deck of cards has to be generated. New deck is generated with NewDeck function:

deck := cards.NewDeck()

Printing all the cards from deck is available from Print function:

deck.Print()

Shuffling the deck is available from Shuffle function:

deck.Shuffle()

Dealing card is available with function Deal which returns hand and remaining cards from deck (5)

Deal(deck, 5)

Saving the deck is available with function SaveToFile and needs filename argument

deck.SaveToFile("myDeck.txt")

Finally, reading deck from file is available with function NewDeckFromFile and needs filename argument

newDeck := NewDeckFromFile("myDeck.txt")

About

Cards

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0