Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Frame.Format %+s does not match documentation #166

Open
thsnr opened this issue Aug 18, 2018 · 0 comments
Open

Frame.Format %+s does not match documentation #166

thsnr opened this issue Aug 18, 2018 · 0 comments

Comments

@thsnr
Copy link

thsnr commented Aug 18, 2018

Description

The documentation of Frame.Format promises:

//    %+s   function name and path of source file relative to the compile time
//          GOPATH separated by \n\t (<funcname>\n\t<path>)
//    %+v   equivalent to %+s:%d

However the absolute path is printed, not relative to GOPATH. This maches what is documented in StackTrace.Format:

//    %+v   Prints filename, function, and line number for each Frame in the stack.

Note no mention of being relative to GOPATH.

Go version: go version go1.10.3 linux/amd64

Steps to reproduce

  1. $GOPATH/src/frame/main.go:
package main

import (
        "fmt"

        "github.com/pkg/errors"
)

type stackTracer interface {
        StackTrace() errors.StackTrace
}

func main() {
        fmt.Printf("%+s\n", errors.New("frame").(stackTracer).StackTrace()[0])
}
  1. go run main.go

Expected output

main.main
        src/frame/main.go

Actual results

With GOPATH=/tmp/gopath:

main.main
        /tmp/gopath/src/frame/main.go

Proposed solution

Change the documentation of Frame.Format to be consistent with StackTrace.Format. If instead %+s is implemented to be relative to GOPATH, then update the documentation of StackTrace.Format. However note that out-of-GOPATH builds are coming in Go 1.11.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant