X7ROOT File Manager
Current Path:
/opt/golang/1.22.0/src/log/slog
opt
/
golang
/
1.22.0
/
src
/
log
/
slog
/
📁
..
📄
attr.go
(2.49 KB)
📄
attr_test.go
(891 B)
📄
doc.go
(12.13 KB)
📄
example_custom_levels_test.go
(2.99 KB)
📄
example_level_handler_test.go
(2.18 KB)
📄
example_log_level_test.go
(1.85 KB)
📄
example_logvaluer_group_test.go
(825 B)
📄
example_logvaluer_secret_test.go
(906 B)
📄
example_test.go
(857 B)
📄
example_wrap_test.go
(1.34 KB)
📄
handler.go
(17.48 KB)
📄
handler_test.go
(19.61 KB)
📁
internal
📄
json_handler.go
(8.05 KB)
📄
json_handler_test.go
(6.48 KB)
📄
level.go
(5.64 KB)
📄
level_test.go
(3.75 KB)
📄
logger.go
(10.22 KB)
📄
logger_test.go
(19.48 KB)
📄
record.go
(5.98 KB)
📄
record_test.go
(4 KB)
📄
slogtest_test.go
(2.61 KB)
📄
text_handler.go
(4.71 KB)
📄
text_handler_test.go
(3.81 KB)
📄
value.go
(12.8 KB)
📄
value_access_benchmark_test.go
(4.29 KB)
📄
value_test.go
(6.08 KB)
Editing: attr_test.go
// Copyright 2022 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package slog import ( "internal/testenv" "testing" "time" ) func TestAttrNoAlloc(t *testing.T) { testenv.SkipIfOptimizationOff(t) // Assign values just to make sure the compiler doesn't optimize away the statements. var ( i int64 u uint64 f float64 b bool s string x any p = &i d time.Duration ) a := int(testing.AllocsPerRun(5, func() { i = Int64("key", 1).Value.Int64() u = Uint64("key", 1).Value.Uint64() f = Float64("key", 1).Value.Float64() b = Bool("key", true).Value.Bool() s = String("key", "foo").Value.String() d = Duration("key", d).Value.Duration() x = Any("key", p).Value.Any() })) if a != 0 { t.Errorf("got %d allocs, want zero", a) } _ = u _ = f _ = b _ = s _ = x }
Upload File
Create Folder