mirror of
https://github.com/etcd-io/bbolt.git
synced 2025-07-11 04:59:16 +00:00
Points: 1. There are lots of duplicated definitions between bolt and guts_cli, which is definitely not good. 2. The implementation in guts_cli also has issue, please refer to https://github.com/etcd-io/bbolt/issues/391. This refactoring can fix the issue. Signed-off-by: Benjamin Wang <wachao@vmware.com>
26 lines
526 B
Go
26 lines
526 B
Go
package common
|
|
|
|
import (
|
|
"fmt"
|
|
"unsafe"
|
|
)
|
|
|
|
// Assert will panic with a given formatted message if the given condition is false.
|
|
func Assert(condition bool, msg string, v ...interface{}) {
|
|
if !condition {
|
|
panic(fmt.Sprintf("assertion failed: "+msg, v...))
|
|
}
|
|
}
|
|
|
|
func LoadBucket(buf []byte) *InBucket {
|
|
return (*InBucket)(unsafe.Pointer(&buf[0]))
|
|
}
|
|
|
|
func LoadPage(buf []byte) *Page {
|
|
return (*Page)(unsafe.Pointer(&buf[0]))
|
|
}
|
|
|
|
func LoadPageMeta(buf []byte) *Meta {
|
|
return (*Meta)(unsafe.Pointer(&buf[PageHeaderSize]))
|
|
}
|