Refactor unsafe pointer usage to use reflect.Type and pointers

Remove internal/danger package and replace unsafe pointer arithmetic with direct pointer manipulation. Update AST node references to use pointers instead of integer offsets. This improves code safety and maintainability.

Co-authored-by: thomas.pelletier <thomas.pelletier@bedrockrobotics.com>
This commit is contained in:
Cursor Agent
2026-01-04 03:11:48 +00:00
parent 9702fae9b8
commit f09f77ab06
10 changed files with 44 additions and 306 deletions
+3 -3
View File
@@ -1,8 +1,8 @@
package tracker
import (
"reflect"
"testing"
"unsafe"
"github.com/pelletier/go-toml/v2/internal/assert"
)
@@ -13,8 +13,8 @@ func TestEntrySize(t *testing.T) {
// and a very good reason.
maxExpectedEntrySize := 48
assert.True(t,
int(unsafe.Sizeof(entry{})) <= maxExpectedEntrySize,
int(reflect.TypeOf(entry{}).Size()) <= maxExpectedEntrySize,
"Expected entry to be less than or equal to %d, got: %d",
maxExpectedEntrySize, int(unsafe.Sizeof(entry{})),
maxExpectedEntrySize, int(reflect.TypeOf(entry{}).Size()),
)
}