• Stars
    star
    225
  • Rank 177,162 (Top 4 %)
  • Language
    Go
  • License
    MIT License
  • Created about 7 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

βœ‚οΈ Is a general library to help modify or set data within data structures and other objects.

Package mold

Project status Build Status Coverage Status Go Report Card GoDoc License

Package mold is a general library to help modify or set data within data structures and other objects.

How can this help me you ask, please see the examples here

Requirements

  • Go 1.18+

Installation

Use go get.

go get -u github.com/go-playground/mold/v4

Examples

Example Description
simple A basic example with custom function.
full A more real life example combining the usage of multiple packages.

Modifiers

These functions modify the data in-place.

Name Description
camel Camel Cases the data.
default Sets the provided default value only if the data is equal to it's default datatype value.
empty Sets the field equal to the datatype default value. e.g. 0 for int.
lcase lowercases the data.
ltrim Trims spaces from the left of the data provided in the params.
rtrim Trims spaces from the right of the data provided in the params.
set Set the provided value.
slug Converts the field to a slug
snake Snake Cases the data.
strip_alpha Strips all ascii characters from the data.
strip_alpha_unicode Strips all unicode characters from the data.
strip_num Strips all ascii numeric characters from the data.
strip_num_unicode Strips all unicode numeric characters from the data.
strip_punctuation Strips all ascii punctuation from the data.
title Title Cases the data.
tprefix Trims a prefix from the value using the provided param value.
trim Trims space from the data.
tsuffix Trims a suffix from the value using the provided param value.
ucase Uppercases the data.
ucfirst Upper cases the first character of the data.

Special Notes: default and set modifiers are special in that they can be used to set the value of a field or underlying type information or attributes and both use the same underlying function to set the data.

Setting a Param will have the following special effects on data types where it's not just the value being set:

  • Chan - param used to set the buffer size, default = 0.
  • Slice - param used to set the capacity, default = 0.
  • Map - param used to set the size, default = 0.
  • time.Time - param used to set the time format OR value, default = time.Now(), utc = time.Now().UTC(), other tries to parse using RFC3339Nano and set a time value.

Scrubbers

These functions obfuscate the specified types within the data for pii purposes.

Name Description
emails Scrubs multiple emails from data.
email Scrubs the data from and specifies the sha name of the same name.
text Scrubs the data from and specifies the sha name of the same name.
name Scrubs the data from and specifies the sha name of the same name.
fname Scrubs the data from and specifies the sha name of the same name.
lname Scrubs the data from and specifies the sha name of the same name.

Special Information

  • To use a comma(,) within your params replace use it's hex representation instead '0x2C' which will be replaced while caching.

Contributing

I am definitely interested in the communities help in adding more scrubbers and modifiers. Please send a PR with tests, and preferably no extra dependencies, at lease until a solid base has been built.

Complimentary Software

Here is a list of software that compliments using this library post decoding.

  • validator - Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving.
  • form - Decodes url.Values into Go value(s) and Encodes Go value(s) into url.Values. Dual Array and Full map support.

License

Distributed under MIT License, please see license file in code for more details.

More Repositories

1

validator

πŸ’―Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving
Go
16,425
star
2

webhooks

🎣 Webhook receiver for GitHub, Bitbucket, GitLab, Gogs
Go
949
star
3

form

πŸš‚ Decodes url.Values into Go value(s) and Encodes Go value(s) into url.Values. Dual Array and Full map support.
Go
750
star
4

pool

🚀 a limited consumer goroutine or unlimited goroutine pool for easier goroutine handling and cancellation
Go
724
star
5

lars

🚨 Is a lightweight, fast and extensible zero allocation HTTP router for Go used to create customizable frameworks.
Go
386
star
6

universal-translator

πŸ’¬ i18n Translator for Go/Golang using CLDR data + pluralization rules
Go
375
star
7

log

πŸ“— Simple, configurable and scalable Structured Logging for Go.
Go
292
star
8

locales

🌎 a set of locales generated from the CLDR Project which can be used independently or within an i18n package; these were built for use with, but not exclusive to https://github.com/go-playground/universal-translator
Go
267
star
9

stats

πŸ“ˆ Monitors Go MemStats + System stats such as Memory, Swap and CPU and sends via UDP anywhere you want for logging etc...
Go
170
star
10

pure

🚱 Is a lightweight HTTP router that sticks to the std "net/http" implementation
Go
149
star
11

overalls

πŸ‘–Multi-Package go project coverprofile for tools like goveralls
Go
114
star
12

statics

πŸ“ Embeds static resources into go files for single binary compilation + works with http.FileSystem + symlinks
Go
68
star
13

colors

🎨 Go color manipulation, conversion and printing library/utility
Go
67
star
14

assert

❗Basic Assertion Library used along side native go testing, with building blocks for custom assertions
Go
62
star
15

errors

πŸ’₯Error Context, Stack Trace, Types and Tags for full error handling and logging.
Go
61
star
16

kms

πŸ”ͺ Is a library that aids in graceful shutdown of a process/application
Go
47
star
17

pkg

⭐ pkg extends the core go packages with missing or additional functionality built in. All packages correspond to the std go package name with an additional suffix of `ext` to avoid naming conflicts.
Go
42
star
18

tz

Timezone Country and Zone data generated from timezonedb.com
Go
30
star
19

generate

πŸƒruns go generate recursively on a specified path or environment variable and can filter by regex
Go
30
star
20

justdoit

simple auto-compile daemon that just works
Go
19
star
21

spoon

library + program to help making zero downtime, self-upgrading programs and servers.
Go
16
star
22

retry

πŸ”„ Retry provides a set of standardized common components and abstracts away some code that normally is duplicated
Go
16
star
23

ansi

⬛ ansi contains a bunch of constants and possibly additional terminal related functionality in the future.
Go
14
star
24

sensitive

provides base types who's values should never be seen by the human eye, but still used for configuration.
Go
14
star
25

ksql

a JSON data expression lexer, parser, cli and library
Go
13
star
26

backoff

:bowtie: Backoff uses an exponential backoff algorithm to backoff between retries with optional auto-tuning functionality.
Go
12
star
27

cache

Contains multiple in-memory cache implementations including LRU & LFU
Go
11
star
28

assets

Asset Pipeline for Go HTML applications
Go
8
star
29

ws

πŸ™Œ ws creates a hub for WebSocket connections and abstracts away allot of the boilerplate code for managing connections using Gorilla WebSocket
Go
8
star
30

itertools

Go Iteration tools with a rusty flavour
Go
7
star
31

livereload

πŸ” is an asset live-reload library that allows easy registration of path & file change monitoring and notifications for https://github.com/livereload/livereload-js
JavaScript
6
star
32

relay-client-go

This package is a Go client for the Relay Job Runner https://github.com/rust-playground/relay-rs
Go
5
star
33

backoff-sys

Bare building blocks for backing off and can be used to build more complex backoff packages
Go
4
star
34

mongostore

πŸ”‘ Gorilla's session store implementation using MongoDB
Go
4
star
35

bundler

Generic Bundler to concatenate any type of files using a custom left and right delimiter, i.e. css or js files
Go
4
star
36

wave

〰️ Package wave is a thin helper layer on top of Go's net/rpc
Go
1
star