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 Go Syntax Error Return Values

Cristian Gerardo Hernandez Barrios
Cristian Gerardo Hernandez Barrios
28,382 Points

I don't understand

Please help me, i'm stuck in this function..--

src/code.my.com/git/files/files.go
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
akhter ali
15,778 Points

Edit 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
Cristian Gerardo Hernandez Barrios
28,382 Points

it'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
akhter ali
15,778 Points

On the TreeHouse text editor there is a preview button. Please post the output from there as well as your new code.