Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Go Language Go Language Overview Custom Types Interfaces

I think there may be an issue with the type but I'm really not sure the error is terribly vague.

I feel like there may be an issue with declaring different types for this. I'm a little unclear if they should be strings or ints based on the other packages. Overall not sure where to go from here.

src/schedule/schedule.go
package schedule

// DECLARE A Displayable INTERFACE HERE
type Displayable interface {
  Display()
}

// DECLARE A Print FUNCTION HERE
func Print(d Displayable) string {
  return d.Display()
}
src/clock/clock.go
package clock

import "fmt"

type Clock struct {
  Hours int
  Minutes int
}

func (c Clock) Display() {
  fmt.Printf("%02d:%02d", c.Hours, c.Minutes)
}
src/calendar/calendar.go
package calendar

import "fmt"

type Calendar struct {
  Year int
  Month int
  Day int
}

func (c Calendar) Display() {
  fmt.Printf("%04d-%02d-%02d", c.Year, c.Month, c.Day)
}

1 Answer

Robert Stefanic
Robert Stefanic
35,170 Points

The types fine and working as expected. The methods of Display() on Clock and Calendar don't return a string, so why would your interface return a string? The Display() methods just print something to the screen, so there's no need for the Print() to return anything because it calls Display(), which doesn't return anything.

Modify your Print() function so that it doesn't return anything.