helper

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2021 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package helper provides some helper functions for github.com/donyori/gogo/encoding/hex.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExampleDumpConfig

func ExampleDumpConfig(upper bool, bytesPerLine int) *hex.DumpConfig

ExampleDumpConfig returns an example hex.DumpConfig, with a prefix function generated by PrefixBytesNo and a suffix function generated by SuffixQuotedPretty.

upper indicates to use uppercase in the hexadecimal representation. bytesPerLine is the number of bytes to show in one line. If bytesPerLine is non-positive, it will use 16 instead.

func PrefixBytesNo

func PrefixBytesNo(cfg *hex.DumpConfig, upper bool, digits int, initCount int64) func() []byte

PrefixBytesNo creates a function that generates a prefix to show the hexadecimal representation of the offset of the beginning of current line, in bytes.

If cfg != nil, cfg.BlockLen > 0, and cfg.BlocksPerLine > 0, it returns a prefix function used in DumpConfig that generates a prefix representing the byte offset of the beginning of current line, in hexadecimal representation, at least "digits" digits (padding with leading zeros if not enough). If digits is non-positive, it will use 8 instead. upper indicates to use uppercase in the hexadecimal representation. initCount specifies the byte offset of the first line.

Otherwise (cfg == nil, cfg.BlockLen <= 0, or cfg.BlocksPerLine <= 0), it returns nil.

func SuffixQuotedPretty

func SuffixQuotedPretty(cfg *hex.DumpConfig) func(line []byte) []byte

SuffixQuotedPretty creates a function that generates a suffix consisting of " | " and the argument line represented in double-quoted Go string literal.

If cfg != nil, cfg.BlockLen > 0, and cfg.BlocksPerLine > 0, it returns a suffix function used in DumpConfig that generates a suffix consisting of " | " and the argument line represented in double-quoted Go string literal. If the length of line is less than cfg.BlockLen * cfg.BlocksPerLine, it pads spaces before " | ".

Otherwise (cfg == nil, cfg.BlockLen <= 0, or cfg.BlocksPerLine <= 0), it returns nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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