bin

package
v0.6.118 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package bin pretty prints a byte slice.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes added in v0.1.6

func Bytes(p []byte, off ...int) string

Bytes returns the bytes as a Go slice literal that can be used in source code.

func Dump

func Dump(p []byte, off ...int) string

Dump dumps the slice p in a way to help debugging DNS wire-format. Got used to reading decimal [192 12] is a pointer etc., so that's being used here. If the optional off is given this is used as an offset in the buffer.

Output looks like:

    80
	        0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15       0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15

	 0   | 007 101 120 097 109 112 108 101 000 000 250 000 255 000 000 000  |  007   e   x   a   m   p   l   e 000 000 250 000 255 000 000 000
	16   | 000 000 061 011 104 109 097 099 045 115 104 097 050 053 054 000  |  000 000 061 011   h   m   a   c 045   s   h   a   2   5   6 000
	32   | 000 000 104 164 006 221 000 255 000 032 005 003 084 048 105 165  |  000 000   h 164 006 221 000 255 000 032 005 003   T   0   i 165
	48   | 027 037 157 115 234 167 019 146 176 044 217 119 200 195 242 213  |  027 037 157   s 234 167 019 146 176 044 217   w 200 195 242 213
	64   | 186 251 188 127 016 138 199 028 029 021 000 003 000 000 000 000  |  186 251 188 127 016 138 199 028 029 021 000 003 000 000 000 000

Usually called as: t.Logf("\n%s\n", bin.Dump(buf))

Types

This section is empty.

Source Files