Documentation
¶
Overview ¶
Package ncode for twist
Index ¶
- Variables
- func B2N(b []byte) uint64
- func DecodeJSON[T any](b []byte) (T, error)
- func DecodeJSONReadCloser[T any](r io.ReadCloser) (T, error)
- func DecodeJSONReader[T any](rdr io.Reader) (T, error)
- func DecodeRequestBody[T any](w http.ResponseWriter, r *http.Request) (T, error)
- func JSONIndent(a any) []byte
- func JSONString(a any) string
- func N2B[E constraints.Unsigned](n E) []byte
- func ParseBase[T constraints.Unsigned](in string, base int) (T, error)
- func ParseNumber[T constraints.Unsigned](in string) (T, error)
- func Twist[T ~string | ~[]byte](a []string) []T
- func TwistAny[T any, K any](a []T, fn func(v T) K) []K
- func TwistAnySkipError[T any, K any](a []K, fn func(s K) (T, error)) ([]T, error)
- func TwistAnyWithError[T any, K any](a []K, fn func(s K) (T, error)) ([]T, error)
- func TwistBack[T ~string | ~[]byte](a []T) []string
- func TwistFormat[T any](a []T, fn func(v T) string) []string
- func TwistParse[T any](a []string, fn func(s string) (T, error)) ([]T, error)
- func TwistParse2[T any, A any, B any](a []A, b B, fn2 func(a A, b B) (T, error)) ([]T, error)
- func TwistParse2Ptr[T any, A any, B any](a []A, b B, fn2 func(a A, b B) (*T, error)) ([]*T, error)
- func TwistParsePtr[T any](a []string, fn func(s string) (*T, error)) ([]*T, error)
- func VarList[T any, A ~[]T](a ...T) A
- type NCode
Constants ¶
This section is empty.
Variables ¶
var ( Binary = binary.LittleEndian JSON = toJSON )
var DebugJSONRequests = false
var ErrOverflow = errors.New("overflow, possible incorrect data type")
var ErrSkip = errors.New("skip error")
var ErrZeroLength = fmt.Errorf("cannot decode zero length")
ErrZeroLength 404 not found
Functions ¶
func DecodeJSON ¶ added in v0.4.4
func DecodeJSONReadCloser ¶ added in v0.4.4
func DecodeJSONReadCloser[T any](r io.ReadCloser) (T, error)
func DecodeJSONReader ¶ added in v0.4.4
DecodeJSONReader does not close reader. set `DebugJSONRequests = true` for debug logging
func DecodeRequestBody ¶
DecodeRequestBody (and close body)
func JSONIndent ¶ added in v0.4.4
JSONIndent ... eg: ncode.JSON = ncode.JSONIndent
func JSONString ¶ added in v0.4.4
func ParseBase ¶
func ParseBase[T constraints.Unsigned](in string, base int) (T, error)
ParseBase string->~uint
func ParseNumber ¶
func ParseNumber[T constraints.Unsigned](in string) (T, error)
ParseNumber string->~uint
func TwistAnySkipError ¶ added in v0.4.4
TwistAnySkipError in case theres a parsing issue. Errored are skipped and items will be zero-value in returned slice.
Errors are collected
func TwistAnyWithError ¶
TwistAnyWithError in case theres a parsing issue. skip elements (but continue indexes) by returning ErrSkip in fn function
Skipped items will be zero-value in returned slice.
func TwistFormat ¶
TwistFormat array into a string array
func TwistParse ¶
TwistParse strings into any things (with error handling) skip elements (but continue indexes) by returning ErrSkip in fn function
Example:
ncode.TwistParse[url.URL]([]string{"google.com", "myspace.com"}, url.Parse)
TODO: skip without incrementing index
func TwistParse2 ¶ added in v0.4.4
TwistParse2 strings into any things (with error handling) skip elements (but continue indexes) by returning ErrSkip in fn function
Example:
ncode.TwistParse2[url.URL]([]string{"google.com", "myspace.com"}, url.Parse2)
TODO: skip without incrementing index
func TwistParse2Ptr ¶ added in v0.4.4
func TwistParsePtr ¶ added in v0.4.4
Types ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package constraints defines a set of useful constraints to be used with type parameters.
|
Package constraints defines a set of useful constraints to be used with type parameters. |