Documentation ¶
Overview ¶
Package sl has convenience functions for returning pointers to values
Index ¶
- Variables
- func Bool(v bool) *bool
- func Float(v float64) *datatypes.Float64
- func Get(p interface{}, d ...interface{}) interface{}
- func GetOk(p interface{}) (interface{}, bool)
- func Grab(s interface{}, path string, d ...interface{}) interface{}
- func GrabOk(s interface{}, path string) (interface{}, bool)
- func Int(v int) *int
- func String(v string) *string
- func Time(v time.Time) *datatypes.Time
- func Uint(v uint) *uint
- type Error
- type Options
- type VersionInfo
Constants ¶
This section is empty.
Variables ¶
var DefaultLimit = 50
var Version = VersionInfo{
Major: 1,
Minor: 1,
Patch: 3,
Pre: "",
}
Functions ¶
func Float ¶
Float converts the float value provided to a datatypes.Float64 value, and returns a pointer to it
func Get ¶
func Get(p interface{}, d ...interface{}) interface{}
Get returns the value of p, either p itself, or, if p is a pointer, the value that p points to. d is an optional default value to be returned in the event that p is nil. If d is not specified, and p is nil, a type-appropriate zero-value is returned instead.
func GetOk ¶
func GetOk(p interface{}) (interface{}, bool)
GetOk returns the value of p, either p itself, or, if p is a pointer, the value that p points to. If p is nil, a type-appropriate zero-value is returned instead. If p is a value or non-nil pointer, the second return value will be true. Otherwise, it will be false.
func Grab ¶
func Grab(s interface{}, path string, d ...interface{}) interface{}
Grab returns the value specified by the path given, starting from the struct s. If at any point in the path the lookup falls short (i.e. a field is not found), or if the last field in the path is nil itself, a type-appropriate zero-value is returned. This behavior can be overidden by providing a default value.
This is useful for getting values our of deeply nested structures Example: val := sl.Grab(virtualGuest, "Datacenter.Name")
func GrabOk ¶
GrabOk returns the value specified by the path given, starting from the struct s. If at any point in the path the lookup falls short (i.e. a field is not found), or if the last field in the path is nil itself, a type-appropriate zero-value is returned. It returns a second value, a boolean, which will be false if it failed to lookup the value, including if the last field in the path was nil.
This is useful for getting values our of deeply nested structures Example: val, ok := sl.GrabOk(virtualGuest, "Datacenter.Name")
Types ¶
type Error ¶
type Error struct { StatusCode int Exception string `json:"code"` Message string `json:"error"` Wrapped error }
Error contains detailed information about an API error, which can be useful for debugging, or when finer error handling is required than just the mere presence or absence of an error.
Error implements the error interface
type Options ¶
Options contains the individual query parameters that can be applied to a request.
func (*Options) GetRemainingAPICalls ¶ added in v1.1.4
returns Math.Ciel((TotalItems - Limit) / Limit)
func (*Options) SetTotalItems ¶ added in v1.1.4
func (*Options) ValidateLimit ¶ added in v1.1.4
Makes sure the limit is set to something, not 0 or 1. Will set to default if no other limit is set.
type VersionInfo ¶
func (VersionInfo) String ¶
func (v VersionInfo) String() string