util

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package util provides common helper functions for file operations, HTTP, and encoding.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeBase64Content

func DecodeBase64Content(content string) ([]byte, error)

DecodeBase64Content decodes a base64-encoded string and returns the raw bytes.

func DecodeContent

func DecodeContent(content string, encoding string) ([]byte, error)

DecodeContent decodes content based on the specified encoding (base64, gzip, or combined).

func DecodeGzipContent

func DecodeGzipContent(content string) ([]byte, error)

DecodeGzipContent decompresses a gzip-encoded string and returns the raw bytes.

func DecompressGzip

func DecompressGzip(content []byte) ([]byte, error)

DecompressGzip decompresses gzip-compressed bytes and returns the result.

func EnsureDirectoryExists

func EnsureDirectoryExists(dir string) error

EnsureDirectoryExists creates the directory if it does not exist, or returns an error if the path is not a directory.

func ExistsAndExecutable

func ExistsAndExecutable(path string) bool

ExistsAndExecutable returns true if the path exists and has executable permissions.

func HTTPDownloadToFile

func HTTPDownloadToFile(url, dest string) error

HTTPDownloadToFile downloads a URL and writes the response body to a file atomically.

func HTTPLoadBytes

func HTTPLoadBytes(url string) ([]byte, error)

HTTPLoadBytes fetches a URL and returns the response body as bytes.

func MaskPassword

func MaskPassword(r *os.File, w io.Writer) ([]byte, error)

MaskPassword reads a password from the given file, masking input with asterisks.

func PromptPassword

func PromptPassword() (string, bool, error)

PromptPassword prompts for a password with confirmation, returning the password and whether they match.

func RunScript

func RunScript(path string, arg ...string) error

RunScript executes a script file, detecting whether it has a shebang or should use /bin/sh.

func WriteFileAtomic

func WriteFileAtomic(filename string, data []byte, perm os.FileMode) error

WriteFileAtomic writes data to a file atomically using a temporary file and rename.

Types

This section is empty.

Jump to

Keyboard shortcuts

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