tags

package
v0.0.0-...-015e77e Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// JSONTag is the default JSON struct tag to use.
	JSONTag = "json"

	// SecureOption is the tag option to enable sparse encryption of a struct field.
	SecureOption = "secure"

	// HashOption is the tag option to hash a struct field of type string. Defaults to SHA256.
	HashOption = "hash"
)

Variables

This section is empty.

Functions

func HasOption

func HasOption(opts []string, opt string) bool

HasOption checks to see if the tag options contain a specific option.

func IgnoreField

func IgnoreField(name string) bool

IgnoreField checks the name to see if field should be ignored.

func IsSecure

func IsSecure(opts []string) bool

IsSecure checks to see if the secure option is set.

func ParseJSONTag

func ParseJSONTag(tag string) (name string, opts []string)

ParseJSONTag returns the name and options for a JSON struct field tag.

Types

type Hash

type Hash string

Hash provides a type for supported hash function names

const (
	// HashNone is used to indicate no has function was found in the tag options.
	HashNone Hash = ""

	// HashSHA256 sets the HashOption to use sha256. This is the default.
	// TODO: support parsing this from the struct field tag hash option e.g. `...,hash=md5"`
	HashSHA256 = "sha256"
)

func HashName

func HashName(opts []string) Hash

HashName checks to see if the hash option is set. The struct field *MUST BE* type string and capable of holding the decoded hash as a string. If no hash option is found it will return HashNone. Defaults to HashSHA256 (sha256).

func (Hash) String

func (h Hash) String() string

Jump to

Keyboard shortcuts

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