Last active
August 29, 2015 14:07
-
-
Save jochasinga/11a747a45a943982a7f4 to your computer and use it in GitHub Desktop.
Function that takes struct as an argument in Go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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