- Sort Score
- Result 10 results
- Languages All
Results 1 - 1 of 1 for computeExpensiveValue (0.14 sec)
-
src/log/slog/doc.go
calls. Say you need to log some expensive value: slog.Debug("frobbing", "value", computeExpensiveValue(arg)) Even if this line is disabled, computeExpensiveValue will be called. To avoid that, define a type implementing LogValuer: type expensive struct { arg int } func (e expensive) LogValue() slog.Value { return slog.AnyValue(computeExpensiveValue(e.arg)) } Then use a value of that type in log calls:
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Thu Feb 15 14:35:48 UTC 2024 - 12.3K bytes - Viewed (0)