如何正确处理运行时错误.Caller(0)

I'm using runtime.Caller(0) to return the file name:

_, file, _, ok := runtime.Caller(0)
if !ok {
    // What should I do here?
}

I would like to know:

  • Why this function in specific doesn't provide an error?
  • What should I do if it fails? (Panic, fatal error?)
  • What could be wrong to fail? Should I validate at all?

This is my first week using Go, so I might seem like stupid questions if you are already advanced, and I'm sorry for that.

Thanks in advance.

Why this function in specific doesn't provide an error?

That is opinion based.

What should I do if it fails? (Panic, fatal error?)

Whatever fits your needs.

What could be wrong to fail?

Everything. E.g. a binary stripped of debug information.

Should I validate at all?

Yes of course.