Documentation
¶
Overview ¶
Package helpers provides utility functions for normalising and manipulating Git references.
Index ¶
- func GetCustomProperty[PT PropertyType](props map[string]string, key string) PT
- func NewNoopLogger() *slog.Logger
- func NormaliseFullRef[S string | *string](ref S) string
- func NormaliseFullRefPtr[S string | *string](ref S) *string
- func NormaliseRef[S string | *string](ref S) string
- func NormaliseRefPtr[S string | *string](ref S) *string
- func Ptr[T any](v T) *T
- func RespondHTTP(rw http.ResponseWriter, response models.Response, err error)
- func String(p *string) string
- func Truncate(s string, n int) string
- type PropertyType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCustomProperty ¶
func GetCustomProperty[PT PropertyType](props map[string]string, key string) PT
GetCustomProperty is a helper function that retrieves a custom property from a map of string properties.
func NewNoopLogger ¶
NewNoopLogger creates and returns a no-operation logger that discards all log output.
func NormaliseFullRef ¶
NormaliseFullRef returns a fully qualified Git reference string by prefixing "refs/heads/" to the normalized input reference.
func NormaliseFullRefPtr ¶
NormaliseFullRefPtr returns a normalized full Git reference as a string pointer from the given string or string pointer.
func NormaliseRef ¶
NormaliseRef removes the "refs/heads/" prefix from a Git reference string, handling both string and *string input types.
func NormaliseRefPtr ¶
NormaliseRefPtr is a helper function that normalizes a Git reference and returns a pointer to the resulting string.
func Ptr ¶
func Ptr[T any](v T) *T
Ptr returns a pointer to the value passed as an argument. If the value is nil, it returns a nil pointer.
func RespondHTTP ¶
func RespondHTTP(rw http.ResponseWriter, response models.Response, err error)
RespondHTTP writes the response to the http.ResponseWriter.
Types ¶
type PropertyType ¶
PropertyType is an interface that represents a property type that can be either a string or a boolean.