Help us shape the future of Go! Take the 2026 Go Developer Survey

utils

package
v1.321.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package utils provides utility functions for environment variable management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareTimeStrings

func CompareTimeStrings(left, right string) int

CompareTimeStrings compares timestamp strings chronologically.

func GetEnvironmentVariable

func GetEnvironmentVariable(name string, others ...any) string

GetEnvironmentVariable retrieves the value of an environment variable.

Parameters:

  • name: The name of the environment variable to retrieve.
  • defaultValue (if provided): The value to return if the environment variable is not set.
  • required (if provided): A boolean indicating whether the environment variable is required.

Returns:

  • string: The value of the environment variable, or the default value if not set. If the variable is required and not set, the function panics.

func GetEnvironmentVariableAsInteger

func GetEnvironmentVariableAsInteger(name string, others ...any) (int, error)

GetEnvironmentVariableAsInteger retrieves the value of an environment variable and converts it to an integer.

Parameters:

  • name: The name of the environment variable to retrieve.
  • others: Optional variadic parameters:
  • First parameter (if provided): The default integer value to return if the environment variable is not set or empty.
  • Second parameter (if provided): A boolean indicating whether the environment variable is required.

Returns:

  • int: The integer value of the environment variable, or the default value if not set or empty.

  • error: An error if the environment variable cannot be parsed as an integer or if the value is out of range for int.

    Returns nil if no error occurred.

func JoinURL

func JoinURL(base string, parts ...string) string

JoinURL appends path parts to a base URL and returns the original base when the input cannot be parsed, avoiding nil dereferences in callers.

func ParseSecretsYAML

func ParseSecretsYAML(s string) (map[string]string, error)

ParseSecretsYAML parses a YAML mapping of secret names to values. An empty string returns nil, nil.

func ParseTimeString

func ParseTimeString(value string) (time.Time, error)

ParseTimeString parses timestamps produced by Temporal and PocketBase APIs.

func SecretsToAny

func SecretsToAny(secrets map[string]string) map[string]any

SecretsToAny converts parsed secrets to the map[string]any form carried by activity results and API responses. Empty secrets return nil.

func TimeStringAfter

func TimeStringAfter(left, right string) bool

TimeStringAfter reports whether left is chronologically after right.

func TimeStringBefore

func TimeStringBefore(left, right string) bool

TimeStringBefore reports whether left is chronologically before right.

Types

type CredimiError

type CredimiError struct {
	Code      string
	Component string
	Location  string
	Message   string
	Context   []string
}

func (CredimiError) Error

func (e CredimiError) Error() string

Jump to

Keyboard shortcuts

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