Do you mean the line number *in the library function* ??

In general, I think that's an impossible problem.  Consider a somewhat 
convoluted example of a library function:


func Bar(...) {
    ...
    if xyz() {
        blah = true
    }
    if abc() {
        baz = false
    }
    ...
    if blah && flurble() && !baz {
        err = SomeError   // A
    }
    ...
    ...
    if err {
        return 0, err     // B
    }
    ...
}

At what point was it "decided" that SomeError should be returned?  A number 
of conditions had to be met before line A was executed.  If you modified 
the code there, it could record as part of the error value the line number 
at which the err variable was set.  However without modifying the code (or 
changing the language, so that every variable value remembers the line 
number where it was last set), I think the best you could get is the line 
number of B.  And that's not very useful.

Your own code presumably looks something like this:

foo, err := library.Bar(baz)
if err {
    ...
}

This means you already know exactly which function you're calling; the 
error must have "come from" somewhere in that function.  (Of course, that 
function may have used the results from other functions before deciding to 
return an error)

There are only a fixed number of return points from library.Bar - quite 
possible only one.  Would it really help much to know which "return" 
statement was used?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/499ac966-374b-4e3f-9ea7-729c8c1640f0%40googlegroups.com.

Reply via email to