Ecosyste.ms: Packages

An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 5.8% dependent packages on proxy.golang.org
Top 4.7% dependent repos on proxy.golang.org

proxy.golang.org : github.com/hujun-open/cmprule

Package cmprule compare a field of a struct to a specified value, based on a human-friendly rule in text. An example use case is following: User could specify a rule: Creats a CMPRule instance for above rule: cmprule support following golang types of a struct field, along with corresponding pointer types: The default rule format is following: - field_name: the field name of the struct to compare - Op: the compare operator - Value: the vale to compare field_name could have format as "aa.bb.cc" to support nested struct Different type has different Op and Value format: Numberic type: this includes all int/uint/float/time.Time/Time.Duration type in Golang single value: Op: ==,!=,>=,<=,>,< Value: a single number example: 'Stat1 : >= : 20' Range value: return true if the field value is within/not within the range Op: in, notin Value: min,max number, sperated by space example: 'Stat1 : in : 100 200' A list of values: return true if the field value is one/none of the list Op: is, not Value: a list of numbers, sperated by space example: 'Stat1 : is : 100 200 300 400' Notes: for time.Time, the string format is like const TIMEFMTSTR for time.Duration, the string format is whatever supported by time.ParseDuration() string: a list of strings: return true if the field value is one/none of the list Op: same, differ Value: a list of double-quoted string, seperate by space example: 'Result : same : "Passed without error" "Passed with error" -a list of strings: return true if the field value is contains/doesn't contain any string of the list Op: contain, notcontain Value: a list of double-quoted string, seperate by space example: 'Lastlog : contain : "warning" "fail" note: if the string in the value contain '"', use a backslash '\' to escape; like '\"' net.IP: a list of strings: return true if the field value is within/not within to one/any prefix of the list Op: within/notwithin Value: a list of IP prefixes, seperate by space example: 'MgmtAddr : within : 1.1.1.1/24 2001:dead::1/64' Optionally, the rule format could be customized by defining new parsing function and pass it to CMPRule instances, by using CMPRule.SetxxxFunc(), See corresponding function's doc for details.

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/hujun-open/cmprule
Keywords: compare, golang, struct, testing-tools
License: BSD-2-Clause
Latest release: about 1 year ago
First release: about 4 years ago
Namespace: github.com/hujun-open
Dependent packages: 1
Dependent repositories: 1
Stars: 1 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 25 days ago

    Loading...
    Readme
    Loading...