util

package
v0.0.0-...-56c581b Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package util provides utilities for Hive libraries and services.

Package util provides utilities for Hive libraries and services.

Index

Constants

View Source
const DefaultServiceName = "unknown-service"

DefaultServiceName will be returned by ServiceName if no better alternative can be determined.

View Source
const Redacted = "xxxxx"

Redacted will be output in logs in place of sensitive information.

Variables

This section is empty.

Functions

func IsRecoveredPanicError

func IsRecoveredPanicError(err error) bool

IsRecoveredPanicError reports whether an error is a RecoveredPanicError.

func NewRecoveredPanicError

func NewRecoveredPanicError(v any) error

NewRecoveredPanicError returns, as an error, a new RecoveredPanicError.

func RedactURL

func RedactURL(s string) string

RedactURL redacts a URL's userinfo subcomponent, if present.

func ServiceName

func ServiceName() string

ServiceName returns the kebab-case name of the Hive service this executable provides.

func ServiceStateDir

func ServiceStateDir() (string, error)

ServiceStateDir returns the application-specific subdirectory to use for persistent state. The directory will be created if it does not exist, but is not guaranteed to be writable.

func UserStateDir

func UserStateDir() (string, error)

UserStateDir returns the default root directory to use for user-specific state files. Users should create their own application-specific subdirectory within this one and use that.

On Unix systems, it returns $XDG_STATE_HOME as specified by https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html if non-empty, else $HOME/.local/state.

If the location cannot be determined (for example, $HOME is not defined) or the path in $XDG_STATE_HOME is relative, then it will return an error.

Types

type ContextKey

type ContextKey struct {
	// contains filtered or unexported fields
}

ContextKey is a key for use with context.Value. It's used as a pointer so it fits in an interface{} without allocation.

func NewContextKey

func NewContextKey(name string) *ContextKey

func (*ContextKey) String

func (k *ContextKey) String() string

type RecoveredPanicError

type RecoveredPanicError interface {
	error
	RecoveredPanicError() // no-op function to distinguish from other errors.
}

A panic which was recovered.

Jump to

Keyboard shortcuts

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