Documentation
¶
Index ¶
- Constants
- func CopyFile(src string, dst string) (err error)
- func CreatePathIfDoesNotExist(path string) (bool, error)
- func CurrentExecutable() string
- func EmitOnChan(c chan string) func(string) error
- func FileExists(path string) (bool, error)
- func FirstCharacter(in string) string
- func GetAvailableIPFromAddress(address net.Addr) net.IP
- func GetFirstNonLoopbackIP() (string, error)
- func GetStack() []byte
- func NewError(format string, parameters ...interface{}) error
- func NowFileString() string
- func PadStringToLength(original string, padWith string, length int) string
- func PathStrippedOfQuery(path string) string
- func PrintBeforeAndAfterStacks(before []byte, after []byte, t *testing.T)
- func RandomString(length int) string
- func SprintfObject(i interface{}, contents bool) (result string)
- func SprintfObjectContents(i interface{}) (result string, error error)
- func SprintfObjectInstance(i interface{}) string
- func StringAppendWithJoin(left string, join string, right string) (result string)
- func StringOfStringRepeated(component string, count int) string
- type ErrorCode
- type ErrorType
- type ErrorTypeInterface
- func MarshalIndentToJSON(v interface{}, prefix string, indent string) ([]byte, ErrorTypeInterface)
- func MarshalToJSON(v interface{}) ([]byte, ErrorTypeInterface)
- func ReadFile(filename string) ([]byte, ErrorTypeInterface)
- func ReadObjectFromJSONFile(object interface{}, fileName string) ErrorTypeInterface
- func UnmarshalFromJSON(data []byte, v interface{}) ErrorTypeInterface
- func WriteFile(filename string, data []byte, perm os.FileMode) ErrorTypeInterface
- func WriteObjectToJSONFile(object interface{}, fileName string, pretty bool) ErrorTypeInterface
- type JSONSafeTime
- type MashalError
- type ReadFileError
- type UnableToFindExternalIPAddressError
- type UnmarshalError
- type WriteFileError
Constants ¶
const ( UnspecifiedCode = -1 UnspecifiedCodeContext = "goutility" )
Variables ¶
This section is empty.
Functions ¶
func CreatePathIfDoesNotExist ¶
CreatePathIfDoesNotExist ensures the path exists, even if it has to create it. Returns an error if there was a problem checking that the path exists or creating the path. Returns true if the path had to be created, false if the path already existed.
func CurrentExecutable ¶
func CurrentExecutable() string
CurrentExecutable return the name of the current executable
func EmitOnChan ¶
EmitOnChan emit values through a channel, drain the channel if we're full
func FirstCharacter ¶
FirstCharacter return the first character in a string
func GetAvailableIPFromAddress ¶
GetAvailableIPFromAddress retrieves the IP from a net.Addr if one is available
func GetFirstNonLoopbackIP ¶
GetFirstNonLoopbackIP get first non-loopback ip address of the current machine
func NowFileString ¶
func NowFileString() string
NowFileString the current date and time as a file name safe string
func PadStringToLength ¶
PadStringToLength pad string with string until it is equal to or greater than length param and return the result
func PathStrippedOfQuery ¶
PathStrippedOfQuery return the path minus any query
func RandomString ¶
RandomString create a random string of specified length
func SprintfObject ¶
SprintfObject print information about an object to a string, optionally include its contents
func SprintfObjectContents ¶
SprintfObjectContents print contents of an object to a string
func SprintfObjectInstance ¶
func SprintfObjectInstance(i interface{}) string
SprintfObjectInstance print information about an object to a string
func StringAppendWithJoin ¶
StringAppendWithJoin append two strings with a join string accounting for empty strings
func StringOfStringRepeated ¶
StringOfStringRepeated return a string composed of component repeated count times
Types ¶
type ErrorType ¶
type ErrorType struct {
// contains filtered or unexported fields
}
func MakeErrorWithCode ¶
func (ErrorType) CodeContext ¶
func (ErrorType) HasValidCode ¶
type ErrorTypeInterface ¶
type ErrorTypeInterface interface {
Error() string
Message() string
Code() ErrorCode
CodeContext() string
HasValidCode() bool
}
func MarshalIndentToJSON ¶
func MarshalIndentToJSON(v interface{}, prefix string, indent string) ([]byte, ErrorTypeInterface)
func MarshalToJSON ¶
func MarshalToJSON(v interface{}) ([]byte, ErrorTypeInterface)
func ReadFile ¶
func ReadFile(filename string) ([]byte, ErrorTypeInterface)
func ReadObjectFromJSONFile ¶
func ReadObjectFromJSONFile(object interface{}, fileName string) ErrorTypeInterface
ReadObjectFromJSONFile read an object from a JSON file
func UnmarshalFromJSON ¶
func UnmarshalFromJSON(data []byte, v interface{}) ErrorTypeInterface
func WriteObjectToJSONFile ¶
func WriteObjectToJSONFile(object interface{}, fileName string, pretty bool) ErrorTypeInterface
WriteObjectToJSONFile write an object to a JSON file
type JSONSafeTime ¶
func (*JSONSafeTime) Format ¶
func (this *JSONSafeTime) Format() string
func (*JSONSafeTime) MarshalJSON ¶
func (this *JSONSafeTime) MarshalJSON() ([]byte, error)
func (*JSONSafeTime) UnmarshalJSON ¶
func (this *JSONSafeTime) UnmarshalJSON(b []byte) (err error)
type MashalError ¶
type MashalError struct {
ErrorType
// contains filtered or unexported fields
}
region MashalError
func MakeMashalError ¶
func MakeMashalError(object interface{}, error error) MashalError
type ReadFileError ¶
type ReadFileError struct {
ErrorType
// contains filtered or unexported fields
}
region ReadFileError
func MakeReadFileError ¶
func MakeReadFileError(filePath string, error error) ReadFileError
type UnableToFindExternalIPAddressError ¶
type UnableToFindExternalIPAddressError struct {
ErrorType
}
region UnableToFindExternalIPAddressError
func MakeUnableToFindExternalIPAddressError ¶
func MakeUnableToFindExternalIPAddressError() UnableToFindExternalIPAddressError
type UnmarshalError ¶
type UnmarshalError struct {
ErrorType
// contains filtered or unexported fields
}
region UnmarshalError
func MakeUnmashalError ¶
func MakeUnmashalError(object interface{}, error error) UnmarshalError
type WriteFileError ¶
type WriteFileError struct {
ErrorType
// contains filtered or unexported fields
}
region WriteFileError
func MakeWriteFileError ¶
func MakeWriteFileError(filePath string, error error) WriteFileError