Exercises & activities from the go workshop provided by Packt: https://courses.packtpub.com/courses/go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
406 B

  1. package main
  2. import "fmt"
  3. type Speaker interface {
  4. Speak() string
  5. }
  6. type cat struct {
  7. name string
  8. }
  9. func catDetails(c cat) {
  10. fmt.Printf("(%v, %T)\n", c, c)
  11. }
  12. func emptyDetails(s interface{}) {
  13. fmt.Printf("(%v, %T)\n", s, s)
  14. }
  15. func main() {
  16. c := cat{"oreo"}
  17. i := 99
  18. b := false
  19. str := "test"
  20. catDetails(c)
  21. emptyDetails(c)
  22. emptyDetails(i)
  23. emptyDetails(b)
  24. emptyDetails(str)
  25. }