stringorslice

package
v1.21.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: May 23, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StringOrSlice

type StringOrSlice struct {
	// contains filtered or unexported fields
}

StringOrSlice is a type that holds a []string, but marshals to a []string or a string.

func Of

func Of(v ...string) StringOrSlice

Of will build a value that marshals to a JSON array if len(v) > 1, otherwise to a single string

func Slice

func Slice(v []string) StringOrSlice

Slice will build a value that marshals to a JSON array

func String

func String(v string) StringOrSlice

String will build a value that marshals to a single string

func (StringOrSlice) Equal

func (l StringOrSlice) Equal(r StringOrSlice) bool

func (*StringOrSlice) IsEmpty added in v1.19.0

func (s *StringOrSlice) IsEmpty() bool

func (StringOrSlice) MarshalJSON

func (v StringOrSlice) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface.

func (StringOrSlice) String

func (s StringOrSlice) String() string

String returns the string value, or the Itoa of the int value.

func (*StringOrSlice) UnmarshalJSON

func (s *StringOrSlice) UnmarshalJSON(value []byte) error

UnmarshalJSON implements the json.Unmarshaller interface.

func (*StringOrSlice) Value

func (v *StringOrSlice) Value() []string

Jump to

Keyboard shortcuts

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