Go Tutorial Part 4 Functions

Contents
package main

import "fmt"

func main() {
	card := newCard()
	fmt.Println(card)
}

func newCard() string {
	return "Five of Diamonds"
}
  1. newCard(): define function of name
  2. string: return datatype

Files in the same package do not have to be imported

package main
  
func main() {
    printState()
}
package main
  
import "fmt"
  
func printState() {
    fmt.Println("California")
}
func deal(d deck, handSize int) (deck, deck) {
	return d[:handSize], d[handSize:]
}

hand, remainingCards := deal(cards, 5)