helpers

package
v0.1.48 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2024 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

helpers/helpers.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEnvOrDefault added in v0.1.39

func GetEnvOrDefault(envKey string, defaultValue string) string

GetEnvOrDefault returns the value of an environment variable or a default value.

func ParseISO8601Date

func ParseISO8601Date(dateStr string) (time.Time, error)

ParseISO8601Date attempts to parse a string date in ISO 8601 format.

func SafeOpenFile added in v0.1.30

func SafeOpenFile(filePath string) (*os.File, error)

SafeOpenFile opens a file safely after validating and resolving its path.

Types

type JSONDuration added in v0.1.39

type JSONDuration time.Duration

JSONDuration wraps time.Duration for custom JSON unmarshalling.

func ParseJSONDuration added in v0.1.39

func ParseJSONDuration(value string, defaultVal JSONDuration) JSONDuration

ParseJSONDuration attempts to parse a string value as a duration and returns the result or a default value.

func (JSONDuration) Duration added in v0.1.39

func (d JSONDuration) Duration() time.Duration

Duration returns the time.Duration value.

func (JSONDuration) String added in v0.1.39

func (d JSONDuration) String() string

MarshalJSON returns the JSON representation of the duration.

func (*JSONDuration) UnmarshalJSON added in v0.1.39

func (d *JSONDuration) UnmarshalJSON(b []byte) error

UnmarshalJSON parses the duration from JSON string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL