diff --git a/internal/encoder/compiler.go b/internal/encoder/compiler.go index 14344da..3bc5a80 100644 --- a/internal/encoder/compiler.go +++ b/internal/encoder/compiler.go @@ -19,11 +19,14 @@ var ( jsonNumberType = reflect.TypeOf(json.Number("")) cachedOpcodeSets []*OpcodeSet cachedOpcodeMap unsafe.Pointer // map[uintptr]*OpcodeSet - typeAddr = &runtime.TypeAddr{} + typeAddr *runtime.TypeAddr ) func init() { typeAddr = runtime.AnalyzeTypeAddr() + if typeAddr == nil { + typeAddr = &runtime.TypeAddr{} + } cachedOpcodeSets = make([]*OpcodeSet, typeAddr.AddrRange) }