Skip to content

Instantly share code, notes, and snippets.

@jochasinga
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jochasinga/11a747a45a943982a7f4 to your computer and use it in GitHub Desktop.
Save jochasinga/11a747a45a943982a7f4 to your computer and use it in GitHub Desktop.
Function that takes struct as an argument in Go
package main
import "fmt"
type Gopher struct {
kingdom string
color map[string]int
num_legs int
height float32
}
func report(g *Gopher) {
fmt.Println(
"A gopher belongs to kingdom",
g.kingdom,
"and standing over",
g.height,
"feet tall.",
)
}
func main() {
chip := Gopher{
"Animalia",
map[string]int{
"r" : 102,
"g" : 255,
"b" : 255,
},
4, 1.5,
}
report(&chip)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment