MCPcopy Create free account
hub / github.com/coder/agentapi / GetUnexportedField

Function GetUnexportedField

lib/util/unsafe.go:9–12  ·  view source on GitHub ↗

Based on https://stackoverflow.com/a/60598827

(obj *T, fieldName string)

Source from the content-addressed store, hash-verified

7
8// Based on https://stackoverflow.com/a/60598827
9func GetUnexportedField[T any](obj *T, fieldName string) any {
10 field := reflect.ValueOf(obj).Elem().FieldByName(fieldName)
11 return reflect.NewAt(field.Type(), unsafe.Pointer(field.UnsafeAddr())).Elem().Interface()
12}

Callers 1

StartProcessFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected