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 Structs

Jon Roethke
Jon Roethke
621 Points

where is the source code for this so i can figure out why my answer is incorrect? logs aren't detailed enough to help

i'd like to better analyze this question and figure out why my answer is incorrect. It is clearly incorrect (I'm still working through this challenge), I just don't know why or how to move forward because the error, failed test, etc. do not explain well enough how to move forward. On my local machine it works fine on terminal because i can print logs and figure out where the errors are coming from. I cannot do that here. Thank you

src/clock/clock.go
package clock

type Clock struct {
  Hours int
  Minutes int
}

func Noon(c Clock) Clock {
  c.Hours = 12
  c.Minutes = 0
  return c
}

2 Answers

Joe Purdy
Joe Purdy
23,237 Points

The source code for the test Treehouse uses for these challenges isn't directly available for review, however you can click the Preview button above the challenge's text editor to switch to viewing the output from the test case.

This is what the test output for the solution you posted here reads:

# clock
src/clock/clock_test.go:21: not enough arguments in call to Noon
    have ()
    want (Clock)
FAIL    clock [build failed]

This is saying that the test case has no arguments to pass to the Noon function, however your solution wanted an argument of type Clock.

You should revise the function signature to not take any arguments like so:

func Noon() Clock

Keep in mind the challenge was to write a function that returns a new Clock value and not modify an existing Clock value. Because of this there is no need to pass in an existing Clock type to the Noon function since this function should be creating a new Clock and setting its Hours and Minutes fields to represent noon.

Hope that helps out!

Jon Roethke
Jon Roethke
621 Points

Wow, I was totally overcomplicating the challenge. Thank you!

Joe Purdy
Joe Purdy
23,237 Points

No problem! Your first solution was the start of a method which probably would give you more mileage in reality, but the challenge for Structs was a simplification.