You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
type Vertex struct {
ID int
This *Vertex
}
//try to use logger to log it when there is circular pointer
{
....
g1 := Vetex{ID: 55}
g.This &g
logger := slog.New(handler)
logger.LogAttrs(context.Background(), slog.LevelError, "a", slog.Any("test", g))
}
The text was updated successfully, but these errors were encountered:
this is one way to solve the infinite loops issue
other way is to also to add opt-in cache
map[uinptr]string thats map pointer to field to the path to the field
and when you handle pointer/struct you can check if that pointer is in the cache and if it is you can format the log field from the stored path.
The text was updated successfully, but these errors were encountered: