v1.16.9
ADDED: * netx.IsPub * encodingx/hexx Rest are mostly small corrections and docs
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
/*
|
||||
Package hexx aims to extend [encoding/hex] functionality.
|
||||
*/
|
||||
package hexx
|
||||
@@ -0,0 +1,30 @@
|
||||
package hexx
|
||||
|
||||
import (
|
||||
`io`
|
||||
)
|
||||
|
||||
/*
|
||||
HexString returns a custom-formatted hex representation of b.
|
||||
*/
|
||||
func HexString(b []byte, opts ...hexStrFmtrOpt) (out string) {
|
||||
|
||||
// TODO
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
HexStringStream encodes a stream read from r and written into w.
|
||||
|
||||
HexStringStream will return cleanly if r returns no more bytes or if an [io.EOF] is encountered (the [io.EOF] will not be returned).
|
||||
Any other error will immediately halt reading/writing and will b returned in err.
|
||||
|
||||
If w is of a fixed capacity, it must be at least 2x the size of r's capacity.
|
||||
*/
|
||||
func HexStringStream(r io.Reader, w io.Writer, opts ...hexStrFmtrOpt) (read, wrtn uint64, err error) {
|
||||
|
||||
// TODO
|
||||
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package hexx
|
||||
|
||||
/*
|
||||
HexStrWithPrefix sets whether a prefix ("0x" by default, see [HexStrWithPrefixStr])
|
||||
*/
|
||||
func HexStrWithPrefix(pfx bool) (f hexStrFmtrOpt) {
|
||||
|
||||
f = func(h *hexStrFmtr) {
|
||||
if h.pfxStr == "" {
|
||||
h.pfxStr = "0x"
|
||||
}
|
||||
h.pfx = pfx
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
HexStrWithPrefixStr sets the prefix used if a prefix is to be included (see [HexStrWithPrefix]).
|
||||
|
||||
The default is "0x".
|
||||
*/
|
||||
func HexStrWithPrefixStr(pfx string) (f hexStrFmtrOpt) { return func(h *hexStrFmtr) { h.pfxStr = pfx } }
|
||||
|
||||
/*
|
||||
HexStrWithLower uses lowercase or uppercase hex character representation. The default is lowercase.
|
||||
|
||||
To use uppercase, specify this option with lower == false.
|
||||
*/
|
||||
func HexStrWithLower(lower bool) (f hexStrFmtrOpt) { return func(h *hexStrFmtr) { h.lower = lower } }
|
||||
|
||||
/*
|
||||
HexStrWithLeftPad specifies if left zero-padding should be used.
|
||||
|
||||
The default is true.
|
||||
*/
|
||||
func HexStrWithLeftPad(leftPad bool) (f hexStrFmtrOpt) {
|
||||
return func(h *hexStrFmtr) { h.noLeftPad = !leftPad }
|
||||
}
|
||||
|
||||
/*
|
||||
HexStrWithSegLeftPad specifies if left zero-padding should be used for each segment (see [HexStrWithSplit]).
|
||||
|
||||
The default is true.
|
||||
*/
|
||||
func HexStrWithSegLeftPad(segLeftPad bool) (f hexStrFmtrOpt) {
|
||||
return func(h *hexStrFmtr) { h.noSegmentLeftPad = !segLeftPad }
|
||||
}
|
||||
|
||||
/*
|
||||
HexStrWithSplit will split the hex string into "chunks" of numBytes bytes.
|
||||
|
||||
For example:
|
||||
numBytes == 0:
|
||||
0x0123456789abcdef
|
||||
|
||||
numBytes == 1:
|
||||
0x01 0x23 0x45 0x67 0x89 0xab 0xcd 0xef
|
||||
|
||||
numBytes == 2:
|
||||
0x0123 0x4567 0x89ab 0xcdef
|
||||
*/
|
||||
func HexStrWithSplit(numBytes uint) (f hexStrFmtrOpt) {
|
||||
return func(h *hexStrFmtr) { h.segmentBytes = numBytes }
|
||||
}
|
||||
|
||||
// TODO
|
||||
@@ -0,0 +1,16 @@
|
||||
package hexx
|
||||
|
||||
type (
|
||||
hexStrFmtrOpt func(h *hexStrFmtr)
|
||||
|
||||
hexStrFmtr struct {
|
||||
pfx bool
|
||||
pfxStr string
|
||||
lower bool
|
||||
noLeftPad bool
|
||||
noSegmentLeftPad bool
|
||||
segmentBytes uint
|
||||
segmentSep string
|
||||
newlineBytes uint
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user