# README
Swag

Contains a bunch of helper functions for go-openapi and go-swagger projects.
You may also use it standalone for your projects.
- convert between value and pointers for builtin types
- convert from string to builtin types (wraps strconv)
- fast json concatenation
- search in path
- load from file or http
- name mangling
This repo has only few dependencies outside of the standard library:
- YAML utilities depend on
gopkg.in/yaml.v3
github.com/mailru/easyjson v0.7.7
# Functions
AddInitialisms add additional initialisms.
Bool returns a pointer to of the bool value passed in.
BoolMap converts a string map of bool values into a string map of bool pointers.
BoolSlice converts a slice of bool values into a slice of bool pointers.
BoolValue returns the value of the bool pointer passed in or false if the pointer is nil.
BoolValueMap converts a string map of bool pointers into a string map of bool values.
BoolValueSlice converts a slice of bool pointers into a slice of bool values.
BytesToYAMLDoc converts a byte slice into a YAML document.
Camelize an uppercased word.
ConcatJSON concatenates multiple json objects efficiently.
ContainsStrings searches a slice of strings for a case-sensitive match.
ContainsStringsCI searches a slice of strings for a case-insensitive match.
ConvertBool turn a string into a boolean.
ConvertFloat32 turn a string into a float32.
ConvertFloat64 turn a string into a float64.
ConvertInt16 turn a string into an int16.
ConvertInt32 turn a string into an int32.
ConvertInt64 turn a string into an int64.
ConvertInt8 turn a string into an int8.
ConvertUint16 turn a string into an uint16.
ConvertUint32 turn a string into an uint32.
ConvertUint64 turn a string into an uint64.
ConvertUint8 turn a string into an uint8.
DynamicJSONToStruct converts an untyped json structure into a struct.
FindInGoSearchPath finds a package in the $GOPATH:$GOROOT.
FindInSearchPath finds a package in a provided lists of paths.
Float32 returns a pointer to of the float32 value passed in.
Float32Map converts a string map of float32 values into a string map of float32 pointers.
Float32Slice converts a slice of float32 values into a slice of float32 pointers.
Float32Value returns the value of the float32 pointer passed in or 0 if the pointer is nil.
Float32ValueMap converts a string map of float32 pointers into a string map of float32 values.
Float32ValueSlice converts a slice of float32 pointers into a slice of float32 values.
Float64 returns a pointer to of the float64 value passed in.
Float64Map converts a string map of float64 values into a string map of float64 pointers.
Float64Slice converts a slice of float64 values into a slice of float64 pointers.
Float64Value returns the value of the float64 pointer passed in or 0 if the pointer is nil.
Float64ValueMap converts a string map of float64 pointers into a string map of float64 values.
Float64ValueSlice converts a slice of float64 pointers into a slice of float64 values.
FormatBool turns a boolean into a string.
FormatFloat32 turns a float32 into a string.
FormatFloat64 turns a float64 into a string.
FormatInt16 turns an int16 into a string.
FormatInt32 turns an int32 into a string.
FormatInt64 turns an int64 into a string.
FormatInt8 turns an int8 into a string.
FormatUint16 turns an uint16 into a string.
FormatUint32 turns an uint32 into a string.
FormatUint64 turns an uint64 into a string.
FormatUint8 turns an uint8 into a string.
FromDynamicJSON turns an object into a properly JSON typed structure.
FullGoSearchPath gets the search paths for finding packages.
Int returns a pointer to of the int value passed in.
Int32 returns a pointer to of the int32 value passed in.
Int32Map converts a string map of int32 values into a string map of int32 pointers.
Int32Slice converts a slice of int32 values into a slice of int32 pointers.
Int32Value returns the value of the int32 pointer passed in or 0 if the pointer is nil.
Int32ValueMap converts a string map of int32 pointers into a string map of int32 values.
Int32ValueSlice converts a slice of int32 pointers into a slice of int32 values.
Int64 returns a pointer to of the int64 value passed in.
Int64Map converts a string map of int64 values into a string map of int64 pointers.
Int64Slice converts a slice of int64 values into a slice of int64 pointers.
Int64Value returns the value of the int64 pointer passed in or 0 if the pointer is nil.
Int64ValueMap converts a string map of int64 pointers into a string map of int64 values.
Int64ValueSlice converts a slice of int64 pointers into a slice of int64 values.
IntMap converts a string map of int values into a string map of int pointers.
IntSlice converts a slice of int values into a slice of int pointers.
IntValue returns the value of the int pointer passed in or 0 if the pointer is nil.
IntValueMap converts a string map of int pointers into a string map of int values.
IntValueSlice converts a slice of int pointers into a slice of int values.
IsFloat64AJSONInteger allow for integers [-2^53, 2^53-1] inclusive.
IsZero returns true when the value passed into the function is a zero value.
JoinByFormat joins a string array by a known format (e.g.
LoadFromFileOrHTTP loads the bytes from a file or a remote http server based on the path passed in.
LoadFromFileOrHTTPWithTimeout loads the bytes from a file or a remote http server based on the path passed in timeout arg allows for per request overriding of the request timeout.
LoadStrategy returns a loader function for a given path or URI.
NewNameProvider creates a new name provider.
ReadJSON reads json data, prefers finding an appropriate interface to short-circuit the unmarshaler so it takes the fastest option available.
SplitByFormat splits a string by a known format:
ssv: space separated value tsv: tab separated value pipes: pipe (|) separated value csv: comma separated value (default).
SplitHostPort splits a network address into a host and a port.
String returns a pointer to of the string value passed in.
StringMap converts a string map of string values into a string map of string pointers.
StringSlice converts a slice of string values into a slice of string pointers.
StringValue returns the value of the string pointer passed in or "" if the pointer is nil.
StringValueMap converts a string map of string pointers into a string map of string values.
StringValueSlice converts a slice of string pointers into a slice of string values.
Time returns a pointer to of the time.Time value passed in.
TimeMap converts a string map of time.Time values into a string map of time.Time pointers.
TimeSlice converts a slice of time.Time values into a slice of time.Time pointers.
TimeValue returns the value of the time.Time pointer passed in or time.Time{} if the pointer is nil.
TimeValueMap converts a string map of time.Time pointers into a string map of time.Time values.
TimeValueSlice converts a slice of time.Time pointers into a slice of time.Time values.
ToCommandName lowercases and underscores a go type name.
ToDynamicJSON turns an object into a properly JSON typed structure.
ToFileName lowercases and underscores a go type name.
ToGoName translates a swagger name which can be underscored or camel cased to a name that golint likes.
ToHumanNameLower represents a code name as a human series of words.
ToHumanNameTitle represents a code name as a human series of words with the first letters titleized.
ToJSONName camelcases a name which can be underscored or pascal cased.
ToVarName camelcases a name which can be underscored or pascal cased.
Uint returns a pointer to of the uint value passed in.
Uint16 returns a pointer to of the uint16 value passed in.
Uint16Map converts a string map of uint16 values into a string map of uint16 pointers.
Uint16Slice converts a slice of uint16 values into a slice of uint16 pointers.
Uint16Value returns the value of the uint16 pointer passed in or 0 if the pointer is nil.
Uint16ValueMap converts a string map of uint16 pointers into a string map of uint16 values.
Uint16ValueSlice converts a slice of uint16 pointers into a slice of uint16 values.
Uint32 returns a pointer to of the uint32 value passed in.
Uint32Map converts a string map of uint32 values into a string map of uint32 pointers.
Uint32Slice converts a slice of uint32 values into a slice of uint32 pointers.
Uint32Value returns the value of the uint32 pointer passed in or 0 if the pointer is nil.
Uint32ValueMap converts a string map of uint32 pointers into a string map of uint32 values.
Uint32ValueSlice converts a slice of uint32 pointers into a slice of uint32 values.
Uint64 returns a pointer to of the uint64 value passed in.
Uint64Map converts a string map of uint64 values into a string map of uint64 pointers.
Uint64Slice converts a slice of uint64 values into a slice of uint64 pointers.
Uint64Value returns the value of the uint64 pointer passed in or 0 if the pointer is nil.
Uint64ValueMap converts a string map of uint64 pointers into a string map of uint64 values.
Uint64ValueSlice converts a slice of uint64 pointers into a slice of uint64 values.
UintMap converts a string map of uint values into a string map of uint pointers.
UintSlice converts a slice of uint values into a slice of uint pointers.
UintValue returns the value of the uint pointer passed in or 0 if the pointer is nil.
UintValueMap converts a string map of uint pointers into a string map of uint values.
UintValueSlice converts a slice of uint pointers into a slice of uint values.
WriteJSON writes json data, prefers finding an appropriate interface to short-circuit the marshaler so it takes the fastest option available.
YAMLData loads a yaml document from either http or a file.
YAMLDoc loads a yaml document from either http or a file and converts it to json.
YAMLMatcher matches yaml.
YAMLToJSON converts YAML unmarshaled data into json compatible data.
# Constants
GOPATHKey represents the env key for gopath.
# Variables
DefaultJSONNameProvider the default cache for types.
GoNamePrefixFunc sets an optional rule to prefix go names which do not start with a letter.
LoadHTTPBasicAuthPassword the password to use when load requests require basic auth.
LoadHTTPBasicAuthUsername the username to use when load requests require basic auth.
LoadHTTPCustomHeaders an optional collection of custom HTTP headers for load requests.
LoadHTTPTimeout the default timeout for load requests.
# Structs
CommandLineOptionsGroup represents a group of user-defined command line options.
File represents an uploaded file.
JSONMapItem represents the value of a key in a JSON object held by JSONMapSlice.
NameProvider represents an object capable of translating from go property names to json property names This type is thread-safe.
# Type aliases
JSONMapSlice represent a JSON object, with the order of keys maintained.