util

package
v0.0.0-...-54f910c Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(t *testing.T, q, msg *dns.Msg, expected string)

func CheckResponseEmpty

func CheckResponseEmpty(t *testing.T, q, msg *dns.Msg)

func CheckResponseNxdomain

func CheckResponseNxdomain(t *testing.T, q, msg *dns.Msg)

func CreateQuery

func CreateQuery(qname string, qtype string) *dns.Msg

func GetGidFromString

func GetGidFromString(s string) (int, error)

Get GID from string (either numeric or name)

func GetIdFromString

func GetIdFromString(s string) (uid int, gid int, err error)

Get UID from string (either numeric or name)

func IsGH

func IsGH() bool

func JsonRpcEncoder

func JsonRpcEncoder(method string, params interface{}) (b []byte, id int, err error)

func JsonRpcRequest

func JsonRpcRequest[T any](endpoint, method string, params interface{}) (result T, err error)

func LineReader

func LineReader(r io.Reader, f func(s string) error) (count int, err error)

Call f for each line in io.Reader

func ParseAddr

func ParseAddr(addr string, defaultPort int) (addrs []string, err error)

func SplitId

func SplitId(s string) (uid int, gid int, err error)

Get uid/gid from string

<uid>
<uid>:<gid>
<username>
<username>:<groupname>

func URLReader

func URLReader(url string, f func(s string) error) (int, error)

Open file/url and run f for each line

func UrlOpen

func UrlOpen(arg string) (io.ReadCloser, error)

Open file or http URL

Types

type JsonRpcError

type JsonRpcError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    string `json:"data"`
}

type JsonRpcReq

type JsonRpcReq struct {
	JsonRpc string      `json:"jsonrpc"`
	Id      int         `json:"id"`
	Method  string      `json:"method"`
	Params  interface{} `json:"params"`
}

type JsonRpcResp

type JsonRpcResp struct {
	JsonRpc string          `json:"jsonrpc"`
	Id      int             `json:"id"`
	Error   json.RawMessage `json:"error"`
	Result  json.RawMessage `json:"result"`
}

type MultiFlag

type MultiFlag []string

func (*MultiFlag) Set

func (f *MultiFlag) Set(value string) error

func (*MultiFlag) String

func (f *MultiFlag) String() string

Jump to

Keyboard shortcuts

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