Discover Packages
github.com/samber/hot
internal
package
Version:
v0.7.0
Opens a new window with list of versions in this module.
Published: Jun 27, 2025
License: MIT
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
README
¶
Internal Package
This package contains internal utilities used by the hot cache library.
Benchmark
The NowMicro() function provides microsecond-precision timestamps with better performance than time.Now().
ok github.com/samber/hot 0.182s
goos: darwin
goarch: arm64
pkg: github.com/samber/hot/bench
BenchmarkDevelTime/TimeGo-10 32602948 37.16 ns/op 0 B/op 0 allocs/op
BenchmarkDevelTime/TimeGo-10 32435061 37.34 ns/op 0 B/op 0 allocs/op
BenchmarkDevelTime/TimeGo-10 32238781 36.80 ns/op 0 B/op 0 allocs/op
BenchmarkDevelTime/TimeSyscall-10 74941058 15.93 ns/op 0 B/op 0 allocs/op
BenchmarkDevelTime/TimeSyscall-10 76003882 16.11 ns/op 0 B/op 0 allocs/op
BenchmarkDevelTime/TimeSyscall-10 74914741 15.89 ns/op 0 B/op 0 allocs/op
The syscall-based implementation (TimeSyscall) is approximately 2.3x faster than the standard time.Now() approach.
Expand ▾
Collapse ▴
Documentation
¶
NowMicro returns the current time in microseconds with microsecond precision.
It is approximately twice as fast as time.Now() for high-frequency operations.
This function uses syscall.Gettimeofday for better performance.
NoCopy may be added to structs which must not be copied after the first use.
This is a compile-time safety mechanism to prevent accidental copying of structs
that contain resources that should not be duplicated.
See https://golang.org/issues/8005#issuecomment-190753527 for details.
Note that it must not be embedded, due to the Lock and Unlock methods.
Lock is a no-op method used by the -copylocks checker from `go vet`.
This method helps the static analyzer detect potential copying issues.
Unlock is a no-op method used by the -copylocks checker from `go vet`.
This method helps the static analyzer detect potential copying issues.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.