gomel

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2024 License: CC0-1.0 Imports: 6 Imported by: 0

README

API Documentation Build Status

Gomel

Gomel provides insights on the memory layout of data structures in Go. The gomel(1) command searches for types within a Go module, including all of its dependencies. The target architecture defaults to go env GOARCH.

Run go install github.com/pascaldekloe/gomel/cmd/gomel@latest to build the command into the bin directory of go env GOPATH.

For example, command gomel net.TCPAddr prints the following table. It shows how field Zone takes 16 bytes, starting at byte-index 32 within the struct.

Name	Type	Size	Offset
IP	net.IP	24	0
Port	int	8	24
Zone	string	16	32

Generic types need all of their type parameters specified with extra arguments. The following table is the output from gomel sync/atomic.Pointer float64. Note how the first two fields have no size. The generic parameter (float64) has no effect on the outcome in this example.

Name	Type	Size	Offset
_	[0]*float64	0	0
_	sync/atomic.noCopy	0	0
v	unsafe.Pointer	8	0

Padding is shown as a hypen ('-') in both the name and the type column.

Documentation

Overview

Package gomel provides type information with insights on Go's memory layout.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("no such type")

ErrNotFound signals lookup failure.

Functions

func Find

func Find(mainQuery string, paramQueries ...string) (types.Type, error)

Find returns a type match for mainQuery or an ErrNotFound. Generic types also need paramQueries for each type parameter.

Types

type Field

type Field struct {
	Name     string     // label from source code
	DataType types.Type // payload classification
	DataSize int64      // byte count of payload
	Offset   int64      // byte count within struct
}

Field defines memory from a struct member.

type Layout

type Layout struct {
	DataType types.Type
	Fields   []Field
}

Layout defines a memory structure.

func StructLayout

func StructLayout(t *types.Struct, target types.Sizes) Layout

StructLayout reads the memory structure t for a specific target.

Directories

Path Synopsis
cmd
internal
testset
Package testset provides data structures for testing.
Package testset provides data structures for testing.
testset/other
Package other contributes to package testset.
Package other contributes to package testset.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL