Skip to content

Instantly share code, notes, and snippets.

@kylegrantlucas
Created December 4, 2018 20:11
Show Gist options
  • Save kylegrantlucas/3161a7a33f5b571182612613a34e98db to your computer and use it in GitHub Desktop.
Save kylegrantlucas/3161a7a33f5b571182612613a34e98db to your computer and use it in GitHub Desktop.
Interface example
package main
import "fmt"
type X interface {
GetValue() string
}
type Y struct {
Value string
}
func (y Y) GetValue() string {
return y.Value
}
func print(param X) {
fmt.Print(param.GetValue())
}
func main() {
y := Y{Value: "Hello World"}
print(y)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment