swag

package module
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2025 License: Apache-2.0 Imports: 14 Imported by: 15,288

README

Swag Build Status codecov

Slack Status license Go Reference Go Report Card

Package swag contains a bunch of helper functions for go-openapi and go-swagger projects.

You may also use it standalone for your projects.

swag is one of the foundational building blocks of the go-openapi initiative.

Most repositories in github.com/go-openapi/... depend on it in some way. So does the CLI tool github.com/go-swagger/go-swagger, and the code generated by this tool.

Contents

go-openapi/swag now exposes a collection of relatively independent modules.

Here is what is inside:

  • Module cmdutils

  • utilities to work with CLIs

  • Module conv

  • convert between values and pointers for any types

  • convert from string to builtin types (wraps strconv)

  • require ./typeutils (test dependency)

  • Module fileutils

  • file upload type

  • search in path (deprecated)

  • Module jsonname

    • infer JSON names from go properties
  • Module jsonutils

    • fast json concatenation
    • read and write JSON from and to dynamic go data structures
    • require github.com/mailru/easyjson
  • Module loading

    • load from file or http
    • require ./yamlutils
  • Module mangling

    • name mangling for go
  • Module netutils

    • host, port from address
  • Module stringutils

  • search in slice (with case-insensitive)

  • split/join query parameters as arrays

  • Module typeutils

  • check the zero value for any type

  • Module yamlutils

    • converting YAML to JSON
    • loading YAML into a dynamic YAML document
    • require ./jsonutils
    • require github.com/mailru/easyjson
    • require gopkg.in/yaml.v3

The root module github.com/go-openapi/swag at the repo level maintains a few dependencies outside of the standard library:

  • YAML utilities depend on gopkg.in/yaml.v3
  • JSON utilities github.com/mailru/easyjson

This is not necessarily the case for all sub-modules.

Release notes

v0.25.0 [draft, unreleased]
  • v0.25.0 will remove the dependency to mailru/easyjson by default.
  • users of JSON or YAML utility who want to use easyjson as their prefered JSON marshaler will be able to do so by registering it at runtime.
v0.24.0

With this release, we have largely modernized the API of swag:

  • The traditional swag API is still supported: code that imports swag will still compile and work the same.
  • A deprecation notice is published to encourage consumers of this library to adopt the newer API
  • Deprecation notice
    • configuration through global variables is now deprecated, in favor of options passed as parameters
    • all helper functions are moved to more specialized packages, which are exposed as go modules. Importing such a module would reduce the footprint of dependencies.
    • all functions, variables, constants exposed by the deprecated API have now moved, so that consumers of the new API no longer need to import github.com/go-openapi/swag, but should import the desired sub-module(s).

New with this release:

  • type converters and pointer to value helpers now support generic types
  • name mangling now support pluralized initialisms (issue #46) Strings like "contact IDs" are now recognized as such a plural form and mangled as a linter would expect.
  • performance: small improvements to reduce the overhead of convert/format wrappers (see issues #110, or PR #108)
  • performance: name mangling utilities run ~ 10% faster (PR #115)

Moving forward, no additional feature will be added to the swag API directly.

However, child modules will continue to evolve or some new ones may be added in the future.

Note to contributors

The mono-repo structure comes with some unavoidable extra pains...

  • Testing

The usual go test ./... command, run from the root of this repo won't work any longer to test all submodules.

Each module constitutes an independant unit of test. So you have to run go test inside each module. Or you may take a look at how this is achieved by CI [here] https://github.com/go-openapi/swag/blob/master/.github/workflows/go-test.yml).

There are also some alternative tricks using go work, for local development, if you feel comfortable with go workspaces. Perhaps some day, we'll have a go work test to run all tests without any hack.

  • Releasing

Each module follows its own independant module versioning.

So you have tags like mangling/v0.24.0, fileutils/v0.24.0 etc that are used by go mod and go get to refer to the tagged version of each module specifically.

This means we may release patches etc to each module independently.

We'd like to adopt the rule that modules in this repo would only differ by a patch version (e.g. v0.24.5 vs v0.24.3), and we'll level all modules whenever a minor version is introduced.

A script in ./hack is provided to tag all modules in one go at the same level in one go.

Todos, suggestions and plans

All kinds of contributions are welcome.

A few ideas:

  • Complete the split of dependencies to isolate easyjson from the rest
  • Improve mangling utilities (improve readability, support for capitalized words, better word substitution for non-letter symbols...)
  • Move back to this common shared pot a few of the technical features introduced by go-swagger independently (e.g. mangle go package names, search package with go modules support, ...)
  • Apply a similar mono-repo approach to go-openapi/strfmt which suffer from similar woes: bloated API, imposed dependency to some database driver.

Documentation

Overview

Package swag contains a bunch of helper functions for go-openapi and go-swagger projects.

You may also use it standalone for your projects.

NOTE: all features that were previously exposed as package-level members (constants, variables, functions and types) are now deprecated and are superseded by equivalent features in more specialized sub-packages.

Here is what is inside:

Module cmdutils:

  • utilities to work with CLIs

Module conv:

  • convert between value and pointers for builtin types
  • convert from string to builtin types (wraps strconv)

Module fileutils:

  • file upload type
  • search in path

Module jsonname:

  • json names for go properties

Module jsonutils:

  • fast json concatenation
  • read and write JSON from and to dynamic go data structures

Module loading:

  • load from file or http

Module mangling:

  • name mangling to generate clean identifiers

Module netutils:

  • host, port from address

Module stringutils:

  • find string in list
  • join/split arrays of query parameters

Module typeutils:

  • check the zero value of any type

Module yamlutils:

  • converting YAML to JSON
  • loading YAML into a dynamic YAML document

This repo has a few dependencies outside of the standard library:

Index

Constants

View Source
const GOPATHKey = fileutils.GOPATHKey

GOPATHKey represents the env key for gopath

Deprecated: use fileutils.GOPATHKey instead.

Variables

View Source
var (

	// LoadHTTPTimeout the default timeout for load requests.
	//
	// Deprecated: use [loading.WithTimeout] instead.
	LoadHTTPTimeout = 30 * time.Second

	// LoadHTTPBasicAuthUsername the username to use when load requests require basic auth.
	//
	// Deprecated: use [loading.WithBasicAuth] instead.
	LoadHTTPBasicAuthUsername = ""

	// LoadHTTPBasicAuthPassword the password to use when load requests require basic auth.
	//
	// Deprecated: use [loading.WithBasicAuth] instead.
	LoadHTTPBasicAuthPassword = ""

	// LoadHTTPCustomHeaders an optional collection of custom HTTP headers for load requests.
	//
	// Deprecated: use [loading.WithCustomHeaders] instead.
	LoadHTTPCustomHeaders = map[string]string{}
)
View Source
var DefaultJSONNameProvider = jsonname.DefaultJSONNameProvider

DefaultJSONNameProvider is the default cache for types

Deprecated: use jsonname.DefaultJSONNameProvider instead.

View Source
var GoNamePrefixFunc mangling.PrefixFunc

GoNamePrefixFunc sets an optional rule to prefix go names which do not start with a letter.

GoNamePrefixFunc should not be written to while concurrently using the other mangling functions of this package.

Deprecated: use mangling.WithGoNamePrefixFunc instead.

Functions

func AddInitialisms deprecated

func AddInitialisms(words ...string)

AddInitialisms adds additional initialisms to the default list (see mangling.DefaultInitialisms).

AddInitialisms is not safe to be called concurrently.

Deprecated: use mangling.WithAdditionalInitialisms instead.

func Bool deprecated

func Bool(v bool) *bool

Bool turn a pointer to of the bool value passed in.

Deprecated: use conv.Pointer instead.

func BoolMap deprecated

func BoolMap(src map[string]bool) map[string]*bool

BoolMap converts a string map of bool values into a string map of bool pointers.

Deprecated: use conv.PointerMap instead.

func BoolSlice deprecated

func BoolSlice(src []bool) []*bool

BoolSlice converts a slice of bool values into a slice of bool pointers.

Deprecated: use conv.PointerSlice instead.

func BoolValue deprecated

func BoolValue(v *bool) bool

BoolValue turn the value of the bool pointer passed in or false if the pointer is nil.

Deprecated: use conv.Value instead.

func BoolValueMap deprecated

func BoolValueMap(src map[string]*bool) map[string]bool

BoolValueMap converts a string map of bool pointers into a string map of bool values.

Deprecated: use conv.ValueMap instead.

func BoolValueSlice deprecated

func BoolValueSlice(src []*bool) []bool

BoolValueSlice converts a slice of bool pointers into a slice of bool values.

Deprecated: use conv.ValueSlice instead.

func BytesToYAMLDoc deprecated

func BytesToYAMLDoc(data []byte) (interface{}, error)

BytesToYAMLDoc converts a byte slice into a YAML document

Deprecated: use yamlutils.BytesToYAMLDoc instead.

func Camelize deprecated

func Camelize(word string) string

Camelize a single word.

Deprecated: use mangling.NameMangler.Camelize instead.

func ConcatJSON deprecated

func ConcatJSON(blobs ...[]byte) []byte

ConcatJSON concatenates multiple JSON objects efficiently.

Deprecated: use jsonutils.ConcatJSON instead.

func ContainsStrings deprecated

func ContainsStrings(coll []string, item string) bool

ContainsStrings searches a slice of strings for a case-sensitive match.

Deprecated: use slices.Contains or stringutils.ContainsStrings instead.

func ContainsStringsCI deprecated

func ContainsStringsCI(coll []string, item string) bool

ContainsStringsCI searches a slice of strings for a case-insensitive match.

Deprecated: use stringutils.ContainsStringsCI instead.

func ConvertBool deprecated

func ConvertBool(str string) (bool, error)

ConvertBool turns a string into a boolean.

Deprecated: use conv.ConvertBool instead.

func ConvertFloat32 deprecated

func ConvertFloat32(str string) (float32, error)

ConvertFloat32 turns a string into a float32.

Deprecated: use conv.ConvertFloat32 instead. Alternatively, you may use the generic version conv.ConvertFloat.

func ConvertFloat64 deprecated

func ConvertFloat64(str string) (float64, error)

ConvertFloat64 turns a string into a float64.

Deprecated: use conv.ConvertFloat64 instead. Alternatively, you may use the generic version conv.ConvertFloat.

func ConvertInt16 deprecated

func ConvertInt16(str string) (int16, error)

ConvertInt16 turns a string into an int16.

Deprecated: use conv.ConvertInt16 instead. Alternatively, you may use the generic version conv.ConvertInteger.

func ConvertInt32 deprecated

func ConvertInt32(str string) (int32, error)

ConvertInt32 turns a string into an int32.

Deprecated: use conv.ConvertInt32 instead. Alternatively, you may use the generic version conv.ConvertInteger.

func ConvertInt64 deprecated

func ConvertInt64(str string) (int64, error)

ConvertInt64 turns a string into an int64.

Deprecated: use conv.ConvertInt64 instead. Alternatively, you may use the generic version conv.ConvertInteger.

func ConvertInt8 deprecated

func ConvertInt8(str string) (int8, error)

ConvertInt8 turns a string into an int8.

Deprecated: use conv.ConvertInt8 instead. Alternatively, you may use the generic version conv.ConvertInteger.

func ConvertUint16 deprecated

func ConvertUint16(str string) (uint16, error)

ConvertUint16 turns a string into an uint16.

Deprecated: use conv.ConvertUint16 instead. Alternatively, you may use the generic version conv.ConvertUinteger.

func ConvertUint32 deprecated

func ConvertUint32(str string) (uint32, error)

ConvertUint32 turns a string into an uint32.

Deprecated: use conv.ConvertUint32 instead. Alternatively, you may use the generic version conv.ConvertUinteger.

func ConvertUint64 deprecated

func ConvertUint64(str string) (uint64, error)

ConvertUint64 turns a string into an uint64.

Deprecated: use conv.ConvertUint64 instead. Alternatively, you may use the generic version conv.ConvertUinteger.

func ConvertUint8 deprecated

func ConvertUint8(str string) (uint8, error)

ConvertUint8 turns a string into an uint8.

Deprecated: use conv.ConvertUint8 instead. Alternatively, you may use the generic version conv.ConvertUinteger.

func DynamicJSONToStruct deprecated

func DynamicJSONToStruct(data interface{}, target interface{}) error

DynamicJSONToStruct converts an untyped JSON structure into a target data type.

Deprecated: use jsonutils.FromDynamicJSON instead.

func FindInGoSearchPath deprecated

func FindInGoSearchPath(pkg string) string

FindInGoSearchPath finds a package in the $GOPATH:$GOROOT

Deprecated: use fileutils.FindInGoSearchPath instead.

func FindInSearchPath deprecated

func FindInSearchPath(searchPath, pkg string) string

FindInSearchPath finds a package in a provided lists of paths.

Deprecated: use fileutils.FindInSearchPath instead.

func Float32 deprecated added in v0.19.9

func Float32(v float32) *float32

Float32 turn a pointer to of the float32 value passed in.

Deprecated: use conv.Pointer instead.

func Float32Map deprecated added in v0.19.9

func Float32Map(src map[string]float32) map[string]*float32

Float32Map converts a string map of float32 values into a string map of float32 pointers.

Deprecated: use conv.PointerMap instead.

func Float32Slice deprecated added in v0.19.9

func Float32Slice(src []float32) []*float32

Float32Slice converts a slice of float32 values into a slice of float32 pointers.

Deprecated: use conv.PointerSlice instead.

func Float32Value deprecated added in v0.19.9

func Float32Value(v *float32) float32

Float32Value turn the value of the float32 pointer passed in or 0 if the pointer is nil.

Deprecated: use conv.Value instead.

func Float32ValueMap deprecated added in v0.19.9

func Float32ValueMap(src map[string]*float32) map[string]float32

Float32ValueMap converts a string map of float32 pointers into a string map of float32 values.

Deprecated: use conv.ValueMap instead.

func Float32ValueSlice deprecated added in v0.19.9

func Float32ValueSlice(src []*float32) []float32

Float32ValueSlice converts a slice of float32 pointers into a slice of float32 values.

Deprecated: use conv.ValueSlice instead.

func Float64 deprecated

func Float64(v float64) *float64

Float64 turn a pointer to of the float64 value passed in.

Deprecated: use conv.Pointer instead.

func Float64Map deprecated

func Float64Map(src map[string]float64) map[string]*float64

Float64Map converts a string map of float64 values into a string map of float64 pointers.

Deprecated: use conv.PointerMap instead.

func Float64Slice deprecated

func Float64Slice(src []float64) []*float64

Float64Slice converts a slice of float64 values into a slice of float64 pointers.

Deprecated: use conv.PointerSlice instead.

func Float64Value deprecated

func Float64Value(v *float64) float64

Float64Value turn the value of the float64 pointer passed in or 0 if the pointer is nil.

Deprecated: use conv.Value instead.

func Float64ValueMap deprecated

func Float64ValueMap(src map[string]*float64) map[string]float64

Float64ValueMap converts a string map of float64 pointers into a string map of float64 values.

Deprecated: use conv.ValueMap instead.

func Float64ValueSlice deprecated

func Float64ValueSlice(src []*float64) []float64

Float64ValueSlice converts a slice of float64 pointers into a slice of float64 values.

Deprecated: use conv.ValueSlice instead.

func FormatBool deprecated

func FormatBool(value bool) string

FormatBool turns a boolean into a string.

Deprecated: use conv.FormatBool instead.

func FormatFloat32 deprecated

func FormatFloat32(value float32) string

FormatFloat32 turns a float32 into a string.

Deprecated: use conv.FormatFloat instead.

func FormatFloat64 deprecated

func FormatFloat64(value float64) string

FormatFloat64 turns a float64 into a string.

Deprecated: use conv.FormatFloat instead.

func FormatInt16 deprecated

func FormatInt16(value int16) string

FormatInt16 turns an int16 into a string.

Deprecated: use conv.FormatInteger instead.

func FormatInt32 deprecated

func FormatInt32(value int32) string

FormatInt32 turns an int32 into a string

Deprecated: use conv.FormatInteger instead.

func FormatInt64 deprecated

func FormatInt64(value int64) string

FormatInt64 turns an int64 into a string.

Deprecated: use conv.FormatInteger instead.

func FormatInt8 deprecated

func FormatInt8(value int8) string

FormatInt8 turns an int8 into a string.

Deprecated: use conv.FormatInteger instead.

func FormatUint16 deprecated

func FormatUint16(value uint16) string

FormatUint16 turns an uint16 into a string.

Deprecated: use conv.FormatUinteger instead.

func FormatUint32 deprecated

func FormatUint32(value uint32) string

FormatUint32 turns an uint32 into a string.

Deprecated: use conv.FormatUinteger instead.

func FormatUint64 deprecated

func FormatUint64(value uint64) string

FormatUint64 turns an uint64 into a string.

Deprecated: use conv.FormatUinteger instead.

func FormatUint8 deprecated

func FormatUint8(value uint8) string

FormatUint8 turns an uint8 into a string.

Deprecated: use conv.FormatUinteger instead.

func FromDynamicJSON deprecated

func FromDynamicJSON(data, target interface{}) error

FromDynamicJSON turns a go value into a properly JSON typed structure.

"Dynamic JSON" refers to what you get when unmarshaling JSON into an untyped interface{}, i.e. objects are represented by map[string]interface{}, arrays by []interface{}, and all scalar values are interface{}.

Deprecated: use jsonutils.FromDynamicJSON instead.

func FullGoSearchPath deprecated

func FullGoSearchPath() string

FullGoSearchPath gets the search paths for finding packages

Deprecated: use fileutils.FullGoSearchPath instead.

func Int deprecated

func Int(v int) *int

Int turn a pointer to of the int value passed in.

Deprecated: use conv.Pointer instead.

func Int32 deprecated

func Int32(v int32) *int32

Int32 turn a pointer to of the int32 value passed in.

Deprecated: use conv.Pointer instead.

func Int32Map deprecated

func Int32Map(src map[string]int32) map[string]*int32

Int32Map converts a string map of int32 values into a string map of int32 pointers.

Deprecated: use conv.PointerMap instead.

func Int32Slice deprecated

func Int32Slice(src []int32) []*int32

Int32Slice converts a slice of int32 values into a slice of int32 pointers.

Deprecated: use conv.PointerSlice instead.

func Int32Value deprecated

func Int32Value(v *int32) int32

Int32Value turn the value of the int32 pointer passed in or 0 if the pointer is nil.

Deprecated: use conv.Value instead.

func Int32ValueMap deprecated

func Int32ValueMap(src map[string]*int32) map[string]int32

Int32ValueMap converts a string map of int32 pointers into a string map of int32 values.

Deprecated: use conv.ValueMap instead.

func Int32ValueSlice deprecated

func Int32ValueSlice(src []*int32) []int32

Int32ValueSlice converts a slice of int32 pointers into a slice of int32 values.

Deprecated: use conv.ValueSlice instead.

func Int64 deprecated

func Int64(v int64) *int64

Int64 turn a pointer to of the int64 value passed in.

Deprecated: use conv.Pointer instead.

func Int64Map deprecated

func Int64Map(src map[string]int64) map[string]*int64

Int64Map converts a string map of int64 values into a string map of int64 pointers.

Deprecated: use conv.PointerMap instead.

func Int64Slice deprecated

func Int64Slice(src []int64) []*int64

Int64Slice converts a slice of int64 values into a slice of int64 pointers.

Deprecated: use conv.PointerSlice instead.

func Int64Value deprecated

func Int64Value(v *int64) int64

Int64Value turn the value of the int64 pointer passed in or 0 if the pointer is nil.

Deprecated: use conv.Value instead.

func Int64ValueMap deprecated

func Int64ValueMap(src map[string]*int64) map[string]int64

Int64ValueMap converts a string map of int64 pointers into a string map of int64 values.

Deprecated: use conv.ValueMap instead.

func Int64ValueSlice deprecated

func Int64ValueSlice(src []*int64) []int64

Int64ValueSlice converts a slice of int64 pointers into a slice of int64 values.

Deprecated: use conv.ValueSlice instead.

func IntMap deprecated

func IntMap(src map[string]int) map[string]*int

IntMap converts a string map of int values into a string map of int pointers.

Deprecated: use conv.PointerMap instead.

func IntSlice deprecated

func IntSlice(src []int) []*int

IntSlice converts a slice of int values into a slice of int pointers.

Deprecated: use conv.PointerSlice instead.

func IntValue deprecated

func IntValue(v *int) int

IntValue turn the value of the int pointer passed in or 0 if the pointer is nil.

Deprecated: use conv.Value instead.

func IntValueMap deprecated

func IntValueMap(src map[string]*int) map[string]int

IntValueMap converts a string map of int pointers into a string map of int values.

Deprecated: use conv.ValueMap instead.

func IntValueSlice deprecated

func IntValueSlice(src []*int) []int

IntValueSlice converts a slice of int pointers into a slice of int values.

Deprecated: use conv.ValueSlice instead.

func IsFloat64AJSONInteger deprecated

func IsFloat64AJSONInteger(f float64) bool

IsFloat64AJSONInteger allows for integers [-2^53, 2^53-1] inclusive.

Deprecated: use conv.IsFloat64AJSONInteger instead.

func IsZero deprecated

func IsZero(data interface{}) bool

IsZero returns true when the value passed into the function is a zero value. This allows for safer checking of interface values.

Deprecated: use typeutils.IsZero instead.

func JoinByFormat deprecated

func JoinByFormat(data []string, format string) []string

JoinByFormat joins a string array by a known format (e.g. swagger's collectionFormat attribute).

Deprecated: use stringutils.JoinByFormat instead.

func LoadFromFileOrHTTP deprecated

func LoadFromFileOrHTTP(pth string, opts ...loading.Option) ([]byte, error)

LoadFromFileOrHTTP loads the bytes from a file or a remote http server based on the provided path.

Deprecated: use loading.LoadFromFileOrHTTP instead.

func LoadFromFileOrHTTPWithTimeout deprecated

func LoadFromFileOrHTTPWithTimeout(pth string, timeout time.Duration, opts ...loading.Option) ([]byte, error)

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.

Deprecated: use loading.LoadFileOrHTTP with the loading.WithTimeout option instead.

func LoadStrategy deprecated

func LoadStrategy(pth string, local, remote func(string) ([]byte, error), opts ...loading.Option) func(string) ([]byte, error)

LoadStrategy returns a loader function for a given path or URL.

Deprecated: use loading.LoadStrategy instead.

func ReadJSON deprecated

func ReadJSON(data []byte, value interface{}) error

ReadJSON reads json data.

Deprecated: use jsonutils.ReadJSON instead.

func SplitByFormat deprecated

func SplitByFormat(data, format string) []string

SplitByFormat splits a string by a known format.

Deprecated: use stringutils.SplitByFormat instead.

func SplitHostPort deprecated

func SplitHostPort(addr string) (host string, port int, err error)

SplitHostPort splits a network address into a host and a port.

Deprecated: use netutils.SplitHostPort instead.

func String deprecated

func String(v string) *string

String turn a pointer to of the string value passed in.

Deprecated: use conv.Pointer instead.

func StringMap deprecated

func StringMap(src map[string]string) map[string]*string

StringMap converts a string map of string values into a string map of string pointers.

Deprecated: use conv.PointerMap instead.

func StringSlice deprecated

func StringSlice(src []string) []*string

StringSlice converts a slice of string values into a slice of string pointers.

Deprecated: use conv.PointerSlice instead.

func StringValue deprecated

func StringValue(v *string) string

StringValue turn the value of the string pointer passed in or "" if the pointer is nil.

Deprecated: use conv.Value instead.

func StringValueMap deprecated

func StringValueMap(src map[string]*string) map[string]string

StringValueMap converts a string map of string pointers into a string map of string values.

Deprecated: use conv.ValueMap instead.

func StringValueSlice deprecated

func StringValueSlice(src []*string) []string

StringValueSlice converts a slice of string pointers into a slice of string values.

Deprecated: use conv.ValueSlice instead.

func Time deprecated

func Time(v time.Time) *time.Time

Time turn a pointer to of the time.Time value passed in.

Deprecated: use conv.Pointer instead.

func TimeMap deprecated

func TimeMap(src map[string]time.Time) map[string]*time.Time

TimeMap converts a string map of time.Time values into a string map of time.Time pointers.

Deprecated: use conv.PointerMap instead.

func TimeSlice deprecated

func TimeSlice(src []time.Time) []*time.Time

TimeSlice converts a slice of time.Time values into a slice of time.Time pointers.

Deprecated: use conv.PointerSlice instead.

func TimeValue deprecated

func TimeValue(v *time.Time) time.Time

TimeValue turn the value of the time.Time pointer passed in or time.Time{} if the pointer is nil.

Deprecated: use conv.Value instead.

func TimeValueMap deprecated

func TimeValueMap(src map[string]*time.Time) map[string]time.Time

TimeValueMap converts a string map of time.Time pointers into a string map of time.Time values.

Deprecated: use conv.ValueMap instead.

func TimeValueSlice deprecated

func TimeValueSlice(src []*time.Time) []time.Time

TimeValueSlice converts a slice of time.Time pointers into a slice of time.Time values

Deprecated: use conv.ValueSlice instead.

func ToCommandName deprecated

func ToCommandName(name string) string

ToCommandName lowercases and underscores a go type name.

Deprecated: use mangling.NameMangler.ToCommandName instead.

func ToDynamicJSON deprecated

func ToDynamicJSON(value interface{}) interface{}

ToDynamicJSON turns a go value into a properly JSON untyped structure.

It is the same as FromDynamicJSON, but doesn't check for errors.

Deprecated: this function is a misnomer and is unsafe. Use jsonutils.FromDynamicJSON instead.

func ToFileName deprecated

func ToFileName(name string) string

ToFileName lowercases and underscores a go type name.

Deprecated: use mangling.NameMangler.ToFileName instead.

func ToGoName deprecated

func ToGoName(name string) string

ToGoName translates a swagger name which can be underscored or camel cased to a name that golint likes.

Deprecated: use mangling.NameMangler.ToGoName instead.

func ToHumanNameLower deprecated

func ToHumanNameLower(name string) string

ToHumanNameLower represents a code name as a human series of words.

Deprecated: use mangling.NameMangler.ToHumanNameLower instead.

func ToHumanNameTitle deprecated

func ToHumanNameTitle(name string) string

ToHumanNameTitle represents a code name as a human series of words with the first letters titleized.

Deprecated: use mangling.NameMangler.ToHumanNameTitle instead.

func ToJSONName deprecated

func ToJSONName(name string) string

ToJSONName camel-cases a name which can be underscored or pascal-cased.

Deprecated: use mangling.NameMangler.ToJSONName instead.

func ToVarName deprecated

func ToVarName(name string) string

ToVarName camel-cases a name which can be underscored or pascal-cased.

Deprecated: use mangling.NameMangler.ToVarName instead.

func Uint deprecated

func Uint(v uint) *uint

Uint turn a pointer to of the uint value passed in.

Deprecated: use conv.Pointer instead.

func Uint16 deprecated added in v0.19.9

func Uint16(v uint16) *uint16

Uint16 turn a pointer to of the uint16 value passed in.

Deprecated: use conv.Pointer instead.

func Uint16Map deprecated added in v0.19.9

func Uint16Map(src map[string]uint16) map[string]*uint16

Uint16Map converts a string map of uint16 values into a string map of uint16 pointers.

Deprecated: use conv.PointerMap instead.

func Uint16Slice deprecated added in v0.19.9

func Uint16Slice(src []uint16) []*uint16

Uint16Slice converts a slice of uint16 values into a slice of uint16 pointers.

Deprecated: use conv.PointerSlice instead.

func Uint16Value deprecated added in v0.19.9

func Uint16Value(v *uint16) uint16

Uint16Value turn the value of the uint16 pointer passed in or 0 if the pointer is nil.

Deprecated: use conv.Value instead.

func Uint16ValueMap deprecated added in v0.19.9

func Uint16ValueMap(src map[string]*uint16) map[string]uint16

Uint16ValueMap converts a string map of uint16 pointers into a string map of uint16 values.

Deprecated: use conv.ValueMap instead.

func Uint16ValueSlice deprecated added in v0.19.9

func Uint16ValueSlice(src []*uint16) []uint16

Uint16ValueSlice converts a slice of uint16 pointers into a slice of uint16 values.

Deprecated: use conv.ValueSlice instead.

func Uint32 deprecated

func Uint32(v uint32) *uint32

Uint32 turn a pointer to of the uint32 value passed in.

Deprecated: use conv.Pointer instead.

func Uint32Map deprecated

func Uint32Map(src map[string]uint32) map[string]*uint32

Uint32Map converts a string map of uint32 values into a string map of uint32 pointers.

Deprecated: use conv.PointerMap instead.

func Uint32Slice deprecated

func Uint32Slice(src []uint32) []*uint32

Uint32Slice converts a slice of uint32 values into a slice of uint32 pointers.

Deprecated: use conv.PointerSlice instead.

func Uint32Value deprecated

func Uint32Value(v *uint32) uint32

Uint32Value turn the value of the uint32 pointer passed in or 0 if the pointer is nil.

Deprecated: use conv.Value instead.

func Uint32ValueMap deprecated

func Uint32ValueMap(src map[string]*uint32) map[string]uint32

Uint32ValueMap converts a string map of uint32 pointers into a string map of uint32 values.

Deprecated: use conv.ValueMap instead.

func Uint32ValueSlice deprecated

func Uint32ValueSlice(src []*uint32) []uint32

Uint32ValueSlice converts a slice of uint32 pointers into a slice of uint32 values.

Deprecated: use conv.ValueSlice instead.

func Uint64 deprecated

func Uint64(v uint64) *uint64

Uint64 turn a pointer to of the uint64 value passed in.

Deprecated: use conv.Pointer instead.

func Uint64Map deprecated

func Uint64Map(src map[string]uint64) map[string]*uint64

Uint64Map converts a string map of uint64 values into a string map of uint64 pointers.

Deprecated: use conv.PointerMap instead.

func Uint64Slice deprecated

func Uint64Slice(src []uint64) []*uint64

Uint64Slice converts a slice of uint64 values into a slice of uint64 pointers.

Deprecated: use conv.PointerSlice instead.

func Uint64Value deprecated

func Uint64Value(v *uint64) uint64

Uint64Value turn the value of the uint64 pointer passed in or 0 if the pointer is nil.

Deprecated: use conv.Value instead.

func Uint64ValueMap deprecated

func Uint64ValueMap(src map[string]*uint64) map[string]uint64

Uint64ValueMap converts a string map of uint64 pointers into a string map of uint64 values.

Deprecated: use conv.ValueMap instead.

func Uint64ValueSlice deprecated

func Uint64ValueSlice(src []*uint64) []uint64

Uint64ValueSlice converts a slice of uint64 pointers into a slice of uint64 values.

Deprecated: use conv.ValueSlice instead.

func UintMap deprecated

func UintMap(src map[string]uint) map[string]*uint

UintMap converts a string map of uint values into a string map of uint pointers.

Deprecated: use conv.PointerMap instead.

func UintSlice deprecated

func UintSlice(src []uint) []*uint

UintSlice converts a slice of uint values into a slice of uint pointers.

Deprecated: use conv.PointerSlice instead.

func UintValue deprecated

func UintValue(v *uint) uint

UintValue turn the value of the uint pointer passed in or 0 if the pointer is nil.

Deprecated: use conv.Value instead.

func UintValueMap deprecated

func UintValueMap(src map[string]*uint) map[string]uint

UintValueMap converts a string map of uint pointers into a string map of uint values.

Deprecated: use conv.ValueMap instead.

func UintValueSlice deprecated

func UintValueSlice(src []*uint) []uint

UintValueSlice converts a slice of uint pointers into a slice of uint values.

Deprecated: use conv.ValueSlice instead.

func WriteJSON deprecated

func WriteJSON(data interface{}) ([]byte, error)

WriteJSON writes json data.

Deprecated: use jsonutils.WriteJSON instead.

func YAMLData deprecated

func YAMLData(path string) (interface{}, error)

YAMLData loads a yaml document from either http or a file.

Deprecated: use loading.YAMLData instead.

func YAMLDoc deprecated

func YAMLDoc(path string) (json.RawMessage, error)

YAMLDoc loads a yaml document from either http or a file and converts it to json.

Deprecated: use loading.YAMLDoc instead.

func YAMLMatcher deprecated

func YAMLMatcher(path string) bool

YAMLMatcher matches yaml for a file loader.

Deprecated: use loading.YAMLMatcher instead.

func YAMLToJSON deprecated

func YAMLToJSON(data interface{}) (json.RawMessage, error)

YAMLToJSON converts YAML unmarshaled data into json compatible data

Deprecated: use yamlutils.YAMLToJSON instead.

Types

type CommandLineOptionsGroup deprecated

type CommandLineOptionsGroup = cmdutils.CommandLineOptionsGroup

CommandLineOptionsGroup represents a group of user-defined command line options.

Deprecated: use cmdutils.CommandLineOptionsGroup instead.

type File deprecated added in v0.21.0

type File = fileutils.File

File represents an uploaded file.

Deprecated: use fileutils.File instead.

type JSONMapItem deprecated

type JSONMapItem = jsonutils.JSONMapItem

JSONMapItem represents a JSON object, with the order of keys maintained

Deprecated: use jsonutils.JSONMapItem instead.

type JSONMapSlice deprecated

type JSONMapSlice = jsonutils.JSONMapSlice

JSONMapSlice represents a JSON object, with the order of keys maintained

Deprecated: use jsonutils.JSONMapSlice instead, or yamlutils.YAMLMapSlice if you marshal YAML.

type NameProvider deprecated

type NameProvider = jsonname.NameProvider

NameProvider represents an object capable of translating from go property names to json property names.

Deprecated: use jsonname.NameProvider instead.

func NewNameProvider deprecated

func NewNameProvider() *NameProvider

NewNameProvider creates a new name provider

Deprecated: use jsonname.NewNameProvider instead.

Directories

Path Synopsis
cmdutils module
conv module
fileutils module
jsonname module
jsonutils module
loading module
mangling module
netutils module
stringutils module
typeutils module
yamlutils module

Jump to

Keyboard shortcuts

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