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 trialTim Williams
Courses Plus Student 9,267 PointsRuns fine with package main but not package clock
I'm not sure where im going wrong here. The code runs fine in the workspace as well as my own Go set up on desktop but when i submit it here I keep getting errors. Ive solved the problem several different ways and each work in the separate environments. The issue is the number of arguments passed is not sufficient. I thought it was since time is using the struct correctly??
package clock
import "fmt"
type Clock struct {
Hours int
Minutes int
}
// DEFINE A "Noon" FUNCTION HERE
func Noon (c Clock) {
fmt.Println("Hours:",c.Hours,"Minutes:", c.Minutes)
}
func main (){
time:= Clock{Hours:12, Minutes:0}
Noon(time)
}
1 Answer
Steven Parker
231,269 PointsYou're working way too hard! Here's some hints:
- you won't need to print anything
- you won't need to import "fmt"
- you don't need to create a "main" function
- the "Noon" function doesn't need to take any argument(s)
- but it does need to be declared as returning a "Clock"
- the function will require a return, which passes back the "Clock" object
Tim Williams
Courses Plus Student 9,267 PointsHi Steve,
I figured it out shortly after posting this question (and pulling my hair out). I was definitely trying way too hard as the answer was so simple. Instead of mimicking the videos to try and understand, I needed to fully understand the concept of each of these modules and do what was being asked. From there the answer was easy.
Tim Williams
Courses Plus Student 9,267 PointsTim Williams
Courses Plus Student 9,267 PointsForget it, im a dummy once again. It was much simpler than i thought it was. Take the function and pass it the struct. define the struct with new values, return those new values. I hate me...