Releases: go-stack/stack
Go 1.17 modules
This release does not contain any code changes. Most of the changes since the last release are related to CI logistics behind the scenes. The only reason for tagging a new release is to update the go.mod
file for Go 1.17 as described in the Go 1.17 release notes
Module Support
In addition to adding a go.mod file, this release also updates the implementation of the %+s
and %+v
formats to provide semantically equivalent behavior when compiled in either a GOPATH or module based project. All existing tests still pass in both modes. Several cases of using this package in a module aware main program and with stacks that include modules >= v2.0.0 have been manually tested to ensure the results are useful in those cases.
There is one subtle difference in the behavior when using modules. That is, stack frames originating in vendored packages built with the -mod=vendor
flag will report their import path as seen in the source code rather than a path in the vendor folder of the main project. Some may consider this an improvement—having paths that match the import path used in the source seems more natural—but opinions may differ here. Also note that the %#s
and %#v
formats still produce unmodified full paths to the compile time source locations as always.
Use runtime.CallersFrames
This release updates the implementation to use runtime.CallersFrames
to examine stack frame data. CallersFrames was added in Go 1.7, so this package no longer supports versions of Go prior to 1.7. If you need to use Go 1.6 or earlier, you should pin this package to v1.6.0.
Go 1.9 changed the way stack data is returned from runtime.Callers
. The good news is that we can now see stack information for inlined functions. The bad news is that inspecting stack data is generally slower and requires more memory than before.
New Package Name Format Verb
This release adds the %k
formatting verb to output the package name for the function or method of stack.Call
. The unadorned verb outputs only the last segment of the package import path, while the %+k
variety produces the full import path of the package.
Note that %k
was chosen in part because one of this package's forks (https://github.com/getlantern/stack) had chosen it for the same purpose. %p
was considered, but the fmt
package already uses that for formatting pointer values, and we wanted to avoid potential confusion with that use case.
Work around for environments that don't handle sigpanic well.
This release should fix several recent reports that some environments don't handle the intentional nil
pointer dereference used by this package to cache the address of runtime.sigpanic
. Caching the address of runtime.sigpanic
was a performance optimization, so stack.Trace
is slower in this release as shown by the benchmarks posted here: #12 (comment).
But correctness takes priority over speed, so this release addresses correctness in the simplest way possible. A future release may be able to regain some of the lost performance.
An incomplete list of Issues in other projects that this release is intended to resolve: