Source File
verify.go
Belonging Package
go.etcd.io/bbolt/internal/common
// Copied from https://github.com/etcd-io/etcd/blob/main/client/pkg/verify/verify.gopackage commonimport ()const ENV_VERIFY = "BBOLT_VERIFY"type VerificationType stringconst (ENV_VERIFY_VALUE_ALL VerificationType = "all"ENV_VERIFY_VALUE_ASSERT VerificationType = "assert")func getEnvVerify() string {return strings.ToLower(os.Getenv(ENV_VERIFY))}func ( VerificationType) bool {:= getEnvVerify()return == string(ENV_VERIFY_VALUE_ALL) || == strings.ToLower(string())}// EnableVerifications sets `ENV_VERIFY` and returns a function that// can be used to bring the original settings.func ( VerificationType) func() {:= getEnvVerify()os.Setenv(ENV_VERIFY, string())return func() {os.Setenv(ENV_VERIFY, )}}// EnableAllVerifications enables verification and returns a function// that can be used to bring the original settings.func () func() {return EnableVerifications(ENV_VERIFY_VALUE_ALL)}// DisableVerifications unsets `ENV_VERIFY` and returns a function that// can be used to bring the original settings.func () func() {:= getEnvVerify()os.Unsetenv(ENV_VERIFY)return func() {os.Setenv(ENV_VERIFY, )}}// Verify performs verification if the assertions are enabled.// In the default setup running in tests and skipped in the production code.func ( func()) {if IsVerificationEnabled(ENV_VERIFY_VALUE_ASSERT) {()}}// Assert will panic with a given formatted message if the given condition is false.func ( bool, string, ...any) {if ! {panic(fmt.Sprintf("assertion failed: "+, ...))}}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |