utils

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: MIT Imports: 1 Imported by: 0

README

pkg/utils

Small shared utility functions and timeout constants.

Files

File Role
strings.go String truncation helpers and HTTP timeout constants

Functions

  • TruncateSecret(s, prefixLen, suffixLen) — Safely displays secrets as "sk_live_...3456". Returns "***" if too short, "(empty)" if empty.
  • TruncateEnd(s, maxLen) — Truncates with "..." at the end. Minimum maxLen is 4.

Constants

Constant Value Usage
DefaultHTTPTimeout 30s API calls (auth validation, sync uploads)

When to Add Here vs. Elsewhere

Add a function here only if it's truly generic and reused by multiple packages. Package-specific helpers belong in their package. If in doubt, keep it local — you can always extract later.

Dependencies

Uses: standard library only

Used by: cmd/, pkg/sync/

Documentation

Index

Constants

View Source
const (
	// DefaultHTTPTimeout is used for API calls (validation, sync uploads, etc.)
	DefaultHTTPTimeout = 30 * time.Second
)

HTTP client timeouts

Variables

This section is empty.

Functions

func TruncateEnd

func TruncateEnd(s string, maxLen int) string

TruncateEnd shortens a string for display by keeping the beginning and adding ellipsis at the end if it exceeds maxLen

func TruncateSecret

func TruncateSecret(s string, prefixLen, suffixLen int) string

TruncateSecret safely truncates a secret string for display. Returns a string like "abc123...wxyz" showing prefix and suffix. If the string is too short, returns a masked version.

Types

This section is empty.

Jump to

Keyboard shortcuts

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