Remove support for Go 1.8 and earlier as they are
a. no longer supported upstream
b. lack support for runtime.CallerFrames
Signed-off-by: Dave Cheney <dave@cheney.net>
toperr is not used, but the go compiler itself doesn't detect this
because it's within an anonymous function. However, go/types does
detect this as being unused, which causes any static analysis tools
which uses go/types' type checker to fail with the message "toperr
assigned and not used".
The final result of the benchmarked function is instead assigned to
an exported global variable to ensure the compiler cannot now, nor
in the future optimise away the function calls due to no observable
side effects.
It was chosen to assign the final result, after the benchmark loop,
to the global variable, as this best follows the example set in the
CL https://go-review.googlesource.com/#/c/37195/. As opposed to
having each call to f assign to the global. This also appears to
better align with the original author's intention of toperr.
This change had no observable impact on the benchmark.
Related https://github.com/golang/go/issues/3059.
Related https://github.com/golang/go/issues/8560.
Thanks dominikh for additional clarifications.
Adds testFormatCompleteCompare as additional testing func.
The new function takes a string slice as "want", wherein
stacktraces and non-stacktrace messages are discerned by
strings.ContainsAny(want[i], "\n").
For example usage, see TestFormatWithStack & TestFormatWithMessage.
Introduces WithMessage as well as errors.fundamental, errors.withMessage
and errors.withStack internal types.
Adjust tests for the new wrapped format when combining fundamental and
wrapped errors.
Destructure New/Errorf into two components, a call to the stdlib
errors.New or fmt.Errorf to generate a _fundamental_ error, and then a
call to withStack to attach a stack trace to the message.
Discovered while vendoring this repo, and having a check for trailing
whitespace. (e.g. `git show --check 45e9319`)
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
* Extended stacktrace output
* Make format tests less sensitive to sourcecode prefix
* use testFormatRegexp for all Sprintf tests
* replace output test with sample output
* work around the different fn.Name format in go 1.4
* fix windows tests when there is a drive letter in the source path