Documentation
¶
Index ¶
- Variables
- func BaseURL(u *url.URL) (string, error)
- func BoolMatcher(dst *bool) func(interface{}) error
- func CleanFileName(s string) string
- func ConfirmingFileName(fname string) bool
- func DeepCopy(dst, src string) error
- func HashFromFile(fname string) ([]byte, error)
- func HashFromReader(r io.Reader) ([]byte, error)
- func MakeUniqDir(prefix string) (string, error)
- func MakeUniqFile(prefix string) (string, *os.File, error)
- func PathExists(path string) (bool, error)
- func ReMarshalJSON(dst, src interface{}) error
- func ReMarshalMatcher(dst interface{}) func(interface{}) error
- func StringMatcher(dst *string) func(interface{}) error
- func TimeMatcher(dst *time.Time, format string) func(interface{}) error
- func WriteHashSumToFile(fname, name string, sum []byte) error
- func WriteHashToFile(fname, name string, h hash.Hash, data []byte) error
- func WriteToFile(fname string, wt io.WriterTo) error
- type Client
- type LimitingClient
- func (lc *LimitingClient) Do(req *http.Request) (*http.Response, error)
- func (lc *LimitingClient) Get(url string) (*http.Response, error)
- func (lc *LimitingClient) Head(url string) (*http.Response, error)
- func (lc *LimitingClient) Post(url, contentType string, body io.Reader) (*http.Response, error)
- func (lc *LimitingClient) PostForm(url string, data url.Values) (*http.Response, error)
- type LoggingClient
- func (lc *LoggingClient) Do(req *http.Request) (*http.Response, error)
- func (lc *LoggingClient) Get(url string) (*http.Response, error)
- func (lc *LoggingClient) Head(url string) (*http.Response, error)
- func (lc *LoggingClient) Post(url, contentType string, body io.Reader) (*http.Response, error)
- func (lc *LoggingClient) PostForm(url string, data url.Values) (*http.Response, error)
- type NWriter
- type PathEval
- type PathEvalMatcher
Constants ¶
This section is empty.
Variables ¶
var SemVersion = "0.0.0"
SemVersion the version in semver.org format, MUST be overwritten during the linking stage of the build process
Functions ¶
func BoolMatcher ¶
BoolMatcher stores the matched result in a bool.
func CleanFileName ¶
CleanFileName replaces invalid runes with an underscore and afterwards collapses multiple underscores into one. If the filename does not end with '.json' it will be appended. The filename is converted to lower case. https://docs.oasis-open.org/csaf/csaf/v2.0/csd02/csaf-v2.0-csd02.html#51-filename specifies valid runes as 'a' to 'z', '0' to '9' and '+', '-', '_'.
func ConfirmingFileName ¶
ConfirmingFileName checks if the given filename is confirming the standard.
func HashFromFile ¶
HashFromFile reads a base 16 coded hash sum from a file.
func HashFromReader ¶
HashFromReader reads a base 16 coded hash sum from a reader.
func MakeUniqDir ¶
MakeUniqDir creates a unique named directory with the given prefix. In case of name collisions the current date plus a random number is appended.
func MakeUniqFile ¶
MakeUniqFile creates a unique named file with the given prefix opened in write only mode. In case of name collisions the current date plus a random number is appended.
func ReMarshalJSON ¶
func ReMarshalJSON(dst, src interface{}) error
ReMarshalJSON transforms data from src to dst via JSON marshalling.
func ReMarshalMatcher ¶
func ReMarshalMatcher(dst interface{}) func(interface{}) error
ReMarshalMatcher is an action to re-marshal the result to another type.
func StringMatcher ¶
StringMatcher stores the matched result in a string.
func TimeMatcher ¶
TimeMatcher stores a time with a given format.
func WriteHashSumToFile ¶
WriteHashSumToFile writes a hash sum to file fname.
func WriteHashToFile ¶
WriteHashToFile writes a hash of data to file fname.
Types ¶
type Client ¶
type Client interface { Do(req *http.Request) (*http.Response, error) Get(url string) (*http.Response, error) Head(url string) (*http.Response, error) Post(url, contentType string, body io.Reader) (*http.Response, error) PostForm(url string, data url.Values) (*http.Response, error) }
Client is an interface to abstract http.Client.
type LimitingClient ¶
LimitingClient is a Client implementing rate throttling.
func (*LimitingClient) Get ¶
func (lc *LimitingClient) Get(url string) (*http.Response, error)
Get implements the respective method of the Client interface.
func (*LimitingClient) Head ¶
func (lc *LimitingClient) Head(url string) (*http.Response, error)
Head implements the respective method of the Client interface.
type LoggingClient ¶
type LoggingClient struct {
Client
}
LoggingClient is a client that logs called URLs.
func (*LoggingClient) Get ¶
func (lc *LoggingClient) Get(url string) (*http.Response, error)
Get implements the respective method of the Client interface.
func (*LoggingClient) Head ¶
func (lc *LoggingClient) Head(url string) (*http.Response, error)
Head implements the respective method of the Client interface.
type PathEval ¶
type PathEval struct {
// contains filtered or unexported fields
}
PathEval is a helper to evaluate JSON paths on documents.
func (*PathEval) Eval ¶
Eval evalutes expression expr on document doc. Returns the result of the expression.
func (*PathEval) Extract ¶
func (pe *PathEval) Extract( expr string, action func(interface{}) error, optional bool, doc interface{}, ) error
Extract extracts a value from a given document with a given expression/action.
func (*PathEval) Match ¶
func (pe *PathEval) Match(matcher []PathEvalMatcher, doc interface{}) error
Match matches a list of PathEvalMatcher pairs against a document.
type PathEvalMatcher ¶
type PathEvalMatcher struct { // Expr is the expression to evaluate Expr string // Action is executed with the result of the match. Action func(interface{}) error // Optional expresses if the expression is optional. Optional bool }
PathEvalMatcher is a pair of an expression and an action when doing extractions via PathEval.Match.