mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-22 12:54:53 -05:00
61e21d7ded
- [Go 1.24](https://groups.google.com/g/golang-announce/c/vYMfuq_XO6w)
is currently out for rc1.
- Using it to test unit tests and integration testing it failed horribly
with strange panics and errors, it is caused by
ca63101df4
and Forgejo trying to access the wrong internal data structures that
have been changed in Go 1.24.
- Use the new data structure for Go 1.24 and above.
38 lines
768 B
Go
38 lines
768 B
Go
//go:build go1.24
|
|
|
|
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package log
|
|
|
|
import "unsafe"
|
|
|
|
//go:linkname runtime_getProfLabel runtime/pprof.runtime_getProfLabel
|
|
func runtime_getProfLabel() unsafe.Pointer //nolint
|
|
|
|
// Struct definitions copied from: https://github.com/golang/go/blob/ca63101df47a4467bc80faa654fc19d68e583952/src/runtime/pprof/label.go
|
|
type label struct {
|
|
key string
|
|
value string
|
|
}
|
|
|
|
type LabelSet struct {
|
|
list []label
|
|
}
|
|
|
|
type labelMap struct {
|
|
LabelSet
|
|
}
|
|
|
|
func getGoroutineLabels() map[string]string {
|
|
l := (*labelMap)(runtime_getProfLabel())
|
|
if l == nil {
|
|
return nil
|
|
}
|
|
|
|
m := make(map[string]string, len(l.list))
|
|
for _, label := range l.list {
|
|
m[label.key] = label.value
|
|
}
|
|
return m
|
|
}
|