Documentation
¶
Overview ¶
Package size provides value size operations.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Of ¶
func Of(data interface{}) int
Of returns the size in byte a value(not type) costs.
Since 0.1.0
func Stat ¶
Stat returns a multi line string describe size of every component of a vavlue, such as slice element, struct member:
size_test.my: 48 a: []int32: 36 0: int32: 4 1: int32: 4 2: int32: 4 b: [3]int32: 12 0: int32: 4 1: int32: 4 2: int32: 4
Since 0.1.0
Example ¶
package main
import (
"fmt"
"github.com/openacid/low/size"
)
func main() {
type my struct {
a []int32
b [3]int32
}
v := my{
a: []int32{1, 2, 3},
b: [3]int32{4, 5, 6},
}
fmt.Println(size.Of(v))
got := size.Stat(v, 10, 100)
fmt.Println(got)
}
Output: 48 size_test.my: 48 a: []int32: 36 0: int32: 4 1: int32: 4 2: int32: 4 b: [3]int32: 12 0: int32: 4 1: int32: 4 2: int32: 4
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.