Skip to content

Instantly share code, notes, and snippets.

@sbward
Created July 31, 2014 06:13
Show Gist options
  • Save sbward/e03956c033bbdfa03a37 to your computer and use it in GitHub Desktop.
Save sbward/e03956c033bbdfa03a37 to your computer and use it in GitHub Desktop.
Code sample from your house
package main
import (
"flag"
"fmt"
"math/rand"
"strconv"
"sync"
)
type car struct {
color string
year int
}
type dog struct {
name string
age int
}
func main() {
var debug *bool
debug = flag.Bool("d", false, "Debugging enabled?")
flag.Parse()
greeting, number := "I am Andrew", getFavoriteNumber()
greeting = greeting + " and my favorite number is " + strconv.Itoa(number)
wg := sync.WaitGroup{}
wg.Add(1)
go printGreeting(greeting, &wg)
wg.Wait()
if *debug {
cDog := dog{"stumps", 1}
nDog := dog{"champagne", 2001}
fmt.Println(cDog, nDog)
}
}
func printGreeting(greeting string, wg *sync.WaitGroup) {
fmt.Println(greeting)
wg.Done()
}
func getFavoriteNumber() int {
return rand.Int()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment