All Projects → gookit → filter

gookit / filter

Licence: MIT License
⏳ Provide filtering, sanitizing, and conversion of Golang data. 提供对Golang数据的过滤,净化,转换。

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to filter

romans
A Simple PHP Roman Numerals Library
Stars: ✭ 40 (-24.53%)
Mutual labels:  converter, filter
man-to-md
Converts man pages to Markdown
Stars: ✭ 51 (-3.77%)
Mutual labels:  converter, filter
Bilateral-Filter
A filter that smooths images while preserving edges.
Stars: ✭ 18 (-66.04%)
Mutual labels:  filter
VBA-Arrays
😎 Array functions that are similar JavaScript functions. Example: Push, Pop, Shift, Unshift, Sort, length, toString.
Stars: ✭ 48 (-9.43%)
Mutual labels:  filter
DDBlackWhite
🎨🚫 Make your image black and white
Stars: ✭ 22 (-58.49%)
Mutual labels:  filter
eloquent-mongodb-repository
Eloquent MongoDB Repository Implementation
Stars: ✭ 18 (-66.04%)
Mutual labels:  filter
Kalmanfilter altimeter vario
Kalman filter to estimate altitude and climbrate(sinkrate) by fusing altitude and acceleration sensor data
Stars: ✭ 31 (-41.51%)
Mutual labels:  filter
CodeDroneDIY
The most simple, but working, quadricopter flight controller from scratch, using Arduino Uno/Nano.
Stars: ✭ 68 (+28.3%)
Mutual labels:  filter
ebook-converter
Commandline tool for converting between several e-books formats, based on Calibre project.
Stars: ✭ 21 (-60.38%)
Mutual labels:  converter
currency-converter
💰 Easily convert between 32 currencies
Stars: ✭ 16 (-69.81%)
Mutual labels:  converter
FigmaConvertXib
FigmaConvertXib is a tool for exporting design elements from figma.com and generating files to a projects iOS .xib / Android .xml
Stars: ✭ 111 (+109.43%)
Mutual labels:  converter
filter-c
Elegant Butterworth and Chebyshev filter implemented in C, with float/double precision support. Works well on many platforms. You can also use this package in C++ and bridge to many other languages for good performance.
Stars: ✭ 56 (+5.66%)
Mutual labels:  filter
sublime-atomizr
Convert Sublime Text completions into Atom (or Visual Studio Code) snippets, and vice versa.
Stars: ✭ 12 (-77.36%)
Mutual labels:  converter
mc2skos
Command line script for converting Marc21 Classification and Authority records to SKOS/RDF
Stars: ✭ 18 (-66.04%)
Mutual labels:  converter
HEIC-to-JPG-right-click-converter
HEIC to JPG converter with one click integration into Mac OS X
Stars: ✭ 19 (-64.15%)
Mutual labels:  converter
pikaso
Seamless and headless HTML5 Canvas library
Stars: ✭ 23 (-56.6%)
Mutual labels:  filter
bro-q
Chrome Extension for JSON formatting and jq filtering in your browser.
Stars: ✭ 82 (+54.72%)
Mutual labels:  filter
matchering-cli
🎚️ Simple Matchering 2.0 Command Line Application
Stars: ✭ 28 (-47.17%)
Mutual labels:  filter
csv-to-sqlite
A desktop app to convert CSV files to SQLite databases!
Stars: ✭ 68 (+28.3%)
Mutual labels:  converter
cti-stix-elevator
OASIS Cyber Threat Intelligence (CTI) TC Open Repository: Convert STIX 1.2 XML to STIX 2.x JSON
Stars: ✭ 42 (-20.75%)
Mutual labels:  converter

Filter

GitHub tag (latest SemVer) GoDoc Build Status Actions Status Coverage Status Go Report Card

Package filter provide filtering, sanitizing, and conversion of Golang data.

GoDoc

Func Usage

Quick usage:

str := filter.MustString(23) // "23"

intVal, err := filter.Int("20") // int(20)
strings := filter.Str2Slice("a,b, c", ",") // []string{"a", "b", "c"}

Filtration

Filtering data:

data := map[string]interface{}{
    "name":     " inhere ",
    "age":      "50",
    "money":    "50.34",
    // 
    "remember": "yes",
    //
    "sub1": []string{"1", "2"},
    "tags": "go;lib",
    "str1": " word ",
    "ids":  []int{1, 2, 2, 1},
}
f := filter.New(data)
f.AddRule("money", "float")
f.AddRule("remember", "bool")
f.AddRule("sub1", "strings2ints")
f.AddRule("tags", "str2arr:;")
f.AddRule("ids", "unique")
f.AddRule("str1", "ltrim|rtrim")
f.AddRule("not-exist", "unique")
// add multi
f.AddRules(map[string]string{
    "age": "trim|int",
    "name": "trim|ucFirst",
})

// apply all added rules for data.
f.Filtering() 

// get filtered data
newData := f.FilteredData()
fmt.Printf("%#v\n", newData)
// f.BindStruct(&user)

Output:

map[string]interface {}{
    "remember":true, 
    "sub1":[]int{1, 2}, 
    "tags":[]string{"go", "lib"}, 
    "ids":[]int{2, 1}, 
    "str1":"word", 
    "name":"INHERE", 
    "age":50, 
    "money":50.34
}

Filters & Converters

  • ToBool/Bool(s string) (bool, error)
  • ToFloat/Float(v interface{}) (float64, error)
  • ToInt/Int(v interface{}) (int, error)
  • ToUint/Uint(v interface{}) (uint64, error)
  • ToInt64/Int64(v interface{}) (int64, error)
  • ToString/String(v interface{}) (string, error)
  • MustBool(s string) bool
  • MustFloat(s string) float64
  • MustInt(s string) int
  • MustInt64(s string) int64
  • MustUint(s string) uint64
  • MustString(v interface{}) string
  • Trim(s string, cutSet ...string) string
  • TrimLeft(s string, cutSet ...string) string
  • TrimRight(s string, cutSet ...string) string
  • TrimStrings(ss []string, cutSet ...string) (ns []string)
  • Substr(s string, pos, length int) string
  • Lower/Lowercase(s string) string
  • Upper/Uppercase(s string) string
  • LowerFirst(s string) string
  • UpperFirst(s string) string
  • UpperWord(s string) string
  • Camel/CamelCase(s string, sep ...string) string
  • Snake/SnakeCase(s string, sep ...string) string
  • Email(s string) string
  • URLDecode(s string) string
  • URLEncode(s string) string
  • EscapeJS(s string) string
  • EscapeHTML(s string) string
  • Unique(val interface{}) interface{} Will remove duplicate values, use for []int []int64 []string
  • StrToSlice(s string, sep ...string) []string
  • StrToInts(s string, sep ...string) (ints []int, err error)
  • StrToTime(s string, layouts ...string) (t time.Time, err error)
  • StringsToInts(ss []string) (ints []int, err error)

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].