Documentation
¶
Index ¶
- func AnySlice[T any](vals []T) []any
- func ApplyVariation(tool types.Tool, variation types.ToolVariation)
- func Default[T comparable](val T, def T) T
- func FromBytes(b []byte) *string
- func FromNullableUUID(u uuid.NullUUID) *string
- func FromPGBool[T ~bool](t pgtype.Bool) *T
- func FromPGText[T ~string](t pgtype.Text) *T
- func GenerateRandomSlug(size int) (string, error)
- func GetToolURN(tool types.Tool) (*urn.Tool, error)
- func MarkdownToHTML(md []byte) ([]byte, error)
- func Ptr[T any](v T) *T
- func PtrEmpty[T comparable](v T) *T
- func PtrToPGText(t *string) pgtype.Text
- func PtrToPGTextEmpty(t *string) pgtype.Text
- func PtrValOr[T any](ptr *T, def T) T
- func PtrValOrEmpty[T comparable](ptr *T, def T) T
- func Ternary[T any](condition bool, trueVal, falseVal T) T
- func ToBaseTool(tool *types.Tool) types.BaseToolAttributes
- func ToLower[T ~string](s T) string
- func ToPGText(t string) pgtype.Text
- func ToPGTextEmpty(t string) pgtype.Text
- func ToSlug(s string) string
- type Secret
- func (s Secret) LogValue() slog.Value
- func (s Secret) MarshalJSON() ([]byte, error)
- func (s Secret) MarshalText() ([]byte, error)
- func (s Secret) Reveal() []byte
- func (s *Secret) Scan(value any) error
- func (s Secret) String() string
- func (s *Secret) UnmarshalJSON(data []byte) error
- func (s *Secret) UnmarshalText(text []byte) error
- func (s Secret) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyVariation ¶
func ApplyVariation(tool types.Tool, variation types.ToolVariation)
func Default ¶
func Default[T comparable](val T, def T) T
Default returns the given value or a default if the value is equal to the zero value of the same type. Example:
Default(0, 5) // returns 5
Default("", "foo") // returns "foo"
Default("jane", "joe") // returns "jane"
func FromBytes ¶
FromBytes converts a byte slice to a string pointer. If the byte slice is empty, it returns nil.
func FromNullableUUID ¶
FromNullableUUID converts a uuid.NullUUID to a *string. If the NullUUID is not valid, it returns nil.
func FromPGBool ¶
FromPGBool converts a pgtype.Bool to a bool or subtype of bool. If Bool is not valid, it returns nil.
func FromPGText ¶
FromPGText converts a pgtype.Text to a *string. If the Text is not valid, it returns nil.
func GenerateRandomSlug ¶
GenerateRandomSlug generates a random slug of the given size using lowercase letters and digits. It returns an error if it fails to generate random bytes.
func MarkdownToHTML ¶
func Ptr ¶
func Ptr[T any](v T) *T
Ptr returns a pointer to the given value. This function is useful because it allows you to create pointers to literal values like conv.Ptr(2) or return values from functions/methods.
func PtrEmpty ¶
func PtrEmpty[T comparable](v T) *T
PtrEmpty returns a pointer to the given value or nil if the value is equal to the zero value of the same type. Example:
PtrEmpty(0) // returns nil
PtrEmpty("") // returns nil
PtrEmpty(false) // returns nil
PtrEmpty(2) // returns *int with value 2
func PtrToPGText ¶
PtrToPGText converts a string pointer to a pgtype.Text with Valid set to true regardless of whether the input is an empty string or not.
func PtrToPGTextEmpty ¶
ToPGTextEmpty converts a string pointer to a pgtype.Text with Valid set to true only if the input value is not an empty string.
func PtrValOr ¶
func PtrValOr[T any](ptr *T, def T) T
PtrValOr returns a value of a given pointer or a default if the pointer is is nil. Example:
PtrValOr[int](nil, 5) // returns *int with value 5
PtrValOr(Ptr(""), "foo") // returns ""
PtrValOr(Ptr("jane"), "joe") // returns *string with value "jane"
func PtrValOrEmpty ¶
func PtrValOrEmpty[T comparable](ptr *T, def T) T
PtrValOrEmpty returns a value of a given pointer or a default if the pointer is is nil or the zero value. Example:
PtrValOrEmpty[int](nil, 5) // returns *int with value 5
PtrValOrEmpty(Ptr(""), "foo") // returns "foo"
PtrValOrEmpty(Ptr("jane"), "joe") // returns *string with value "jane"
func ToBaseTool ¶
func ToBaseTool(tool *types.Tool) types.BaseToolAttributes
func ToPGText ¶
ToPGText converts a string to a pgtype.Text with Valid set to true regardless of whether the input is an empty string or not.
func ToPGTextEmpty ¶
ToPGTextEmpty converts a string to a pgtype.Text with Valid set to true only if the input value is not an empty string.
Types ¶
type Secret ¶
type Secret struct {
// contains filtered or unexported fields
}