diff options
| author | Austin Clements <austin@google.com> | 2023-02-05 15:54:33 -0500 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2023-03-10 17:18:27 +0000 |
| commit | f52bede354102a5e16e19381b93d4a469d1286d4 (patch) | |
| tree | c34f5a0a819f760acceee8411612e758fa9fa041 /src/runtime/string.go | |
| parent | dcb4c1c1aad098e6b0da4a64896ff2f98f3a2ad7 (diff) | |
| download | go-f52bede354102a5e16e19381b93d4a469d1286d4.tar.xz | |
runtime: create an API for unwinding inlined frames
We've replicated the code to expand inlined frames in many places in
the runtime at this point. This CL adds a simple iterator API that
abstracts this out.
We also use this to try out a new idea for structuring tests of
runtime internals: rather than exporting this whole internal data type
and API, we write the test in package runtime and import the few bits
of std we need. The idea is that, for tests of internals, it's easier
to inject public APIs from std than it is to export non-public APIs
from runtime. This is discussed more in #55108.
For #54466.
Change-Id: Iebccc04ff59a1509694a8ac0e0d3984e49121339
Reviewed-on: https://go-review.googlesource.com/c/go/+/466096
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/string.go')
| -rw-r--r-- | src/runtime/string.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/runtime/string.go b/src/runtime/string.go index a00976be59..7ac3e66a3a 100644 --- a/src/runtime/string.go +++ b/src/runtime/string.go @@ -345,6 +345,10 @@ func hasPrefix(s, prefix string) bool { return len(s) >= len(prefix) && s[:len(prefix)] == prefix } +func hasSuffix(s, suffix string) bool { + return len(s) >= len(suffix) && s[len(s)-len(suffix):] == suffix +} + const ( maxUint64 = ^uint64(0) maxInt64 = int64(maxUint64 >> 1) |
