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 trialCristian Gerardo Hernandez Barrios
28,382 PointsI don't understand
Please help me, i'm stuck in this function..--
package files
import "os"
func Size(fileName string) int64 {
fileInfo, err := os.Stat(fileName)
if err != nil {
// RETURN THE VALUES 0 AND err
return 0, err
}
// RETURN THE VALUES fileInfo.Size() AND nil
return fileInfo.Size(), nil
}
1 Answer
akhter ali
15,778 PointsEdit for more clarification and understanding: You are missing the error declaration on your function header.
func Size(fileName string) int64
should be more like:
func Size(fileName string) (int64, error)
Since you're returning a 0 and an error code, you need to make sure that the function states what it returns.
Cristian Gerardo Hernandez Barrios
28,382 PointsCristian Gerardo Hernandez Barrios
28,382 Pointsit's not work, i tried your recommendation but it's still not working... sorry if you can't undestand me.... because my english is bad, i'm from latin america.
akhter ali
15,778 Pointsakhter ali
15,778 PointsOn the TreeHouse text editor there is a preview button. Please post the output from there as well as your new code.
Cristian Gerardo Hernandez Barrios
28,382 PointsCristian Gerardo Hernandez Barrios
28,382 PointsThanks its work sorry jejeje