Documentation ¶
Index ¶
- func BuildFullFilePath(filename string) string
- func CloseQuietly(c io.Closer) func()
- func CreateTempFileFromStringData(namePrefix string, contents string) (string, error)
- func DiffAsJson(a interface{}, b interface{}, aName string, bName string) string
- func GetProjectRootDir() string
- func HandleError(r *http.Request, w http.ResponseWriter, err *errors.ServiceError)
- func IsNil[T any](x T) bool
- func IsNotNil[T any](x T) bool
- func LoadOpenAPISpecFromYAML(openapiYAMLBytes []byte) (data []byte, err error)
- func ReadFile(file string) (string, error)
- func ReadFileValueBool(file string, val *bool) error
- func ReadFileValueInt(file string, val *int) error
- func ReadFileValueString(file string, val *string) error
- func ReadJSONFile(filename string, out interface{}) error
- func ReadYamlFile(filename string, out interface{}) (err error)
- func RoundDown(number int, multiple int) int
- func RoundUp(number int, multiple int) int
- func SafeInt64(ptr *int64) int64
- func SafeString(ptr *string) string
- func StringEmpty[T string | *string](x T, trim ...bool) bool
- func StringEqualsIgnoreCase[T string | *string](s1 T, s2 T) bool
- func StringHasPrefixIgnoreCase[T string | *string](s T, prefix T) bool
- func StringHasSuffixIgnoreCase[T string | *string](s T, suffix T) bool
- func WriteJSONResponse(w http.ResponseWriter, code int, payload interface{})
- func WriteStreamJSONResponseWithContentType(w http.ResponseWriter, code int, payload interface{}, contentType string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildFullFilePath ¶
func CloseQuietly ¶
CloseQuietly - Returns a function that closes a `Closer` object without returning any error
func DiffAsJson ¶
func GetProjectRootDir ¶
func GetProjectRootDir() string
GetProjectRootDir returns the root directory of the project. The root directory of the project is the directory that contains the go.mod file which contains the "github.com/bf2fc6cc711aee1a0c2a/kas-fleet-manager" module name.
func HandleError ¶
func HandleError(r *http.Request, w http.ResponseWriter, err *errors.ServiceError)
HandleError handles a service error by returning an appropriate HTTP response with error reason
func LoadOpenAPISpecFromYAML ¶
func ReadFileValueBool ¶
Read the contents of file into boolean value
func ReadFileValueInt ¶
Read the contents of file into integer value
func ReadFileValueString ¶
Read the contents of file into string value
func ReadJSONFile ¶
ReadJSONFile reads a JSON file located in `filename` path and leaves the result in the `out` argument. If the file exists but it is empty or only contain blanks the method succeeds leaving the `out` argument unmodified
func ReadYamlFile ¶
func RoundDown ¶
RoundDown rounds up number to the nearest multiple. number and multiple are expected to be positive
func RoundUp ¶
RoundUp rounds up number to the nearest multiple. number and multiple are expected to be positive
func SafeInt64 ¶
SafeInt64 - Converts an Int64 pointer to an Int64. If the pointer is `nil`, returns 0
func SafeString ¶
SafeString - Converts a string pointer to a string. If the pointer is `nil`, returns the empty string
func StringEmpty ¶
StringEmpty - returns `true` if the value is nil or is the empty string. Works with both `string` and `*string` objects. If `trim` is specified and is `true` trims the string (only first value is considered).
func StringEqualsIgnoreCase ¶
StringEqualsIgnoreCase - Compare 2 strings ignoring the case. Works with both string and *string values. If s1 == s2 == nil, returns `true`
func StringHasPrefixIgnoreCase ¶
StringHasPrefixIgnoreCase - returns true if s starts with T, ignoring the case Works with both string and *string values.
func StringHasSuffixIgnoreCase ¶
StringHasSuffixIgnoreCase - returns true if s ends with T, ignoring the case Works with both string and *string values.
func WriteJSONResponse ¶
func WriteJSONResponse(w http.ResponseWriter, code int, payload interface{})
WriteJSONResponse writes a json HTTP response of the given HTTP status code and response payload
func WriteStreamJSONResponseWithContentType ¶
func WriteStreamJSONResponseWithContentType(w http.ResponseWriter, code int, payload interface{}, contentType string)
WriteJSONResponse writes a HTTP response of the given HTTP status code and response payload with a given content type
Types ¶
This section is empty.