utils

package
v0.7.8 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const NotificationAppName = "Surge"

Variables

View Source
var SuppressNotifications bool

SuppressNotifications can be set to true to prevent desktop notifications. Tests should set this to true via TestMain or init() to avoid notification spam.

Functions

func CleanupLogs

func CleanupLogs(retentionCount int)

CleanupLogs removes old log files, keeping only the most recent retentionCount files

func ConfigureDebug

func ConfigureDebug(dir string)

ConfigureDebug sets the directory for debug logs

func ConvertBytesToHumanReadable

func ConvertBytesToHumanReadable(bytes int64) string

ConvertBytesToHumanReadable converts a given number of bytes into a human-readable format (e.g., KB, MB, GB).

func CopyFile

func CopyFile(src, dst string) error

CopyFile centralizes the rename-fallback copy path used by download finalization.

func CopyRedirectHeaders

func CopyRedirectHeaders(dst, src *http.Request)

CopyRedirectHeaders preserves all headers for same-origin redirects but strips sensitive headers (cookies, auth) for cross-domain redirects.

func Debug

func Debug(format string, args ...any)

Debug writes a message to debug.log file in the configured directory

func DetermineFilename

func DetermineFilename(rawurl string, resp *http.Response) (string, io.Reader, error)

DetermineFilename extracts the filename from a URL and HTTP response, applying various heuristics. It returns the determined filename, a new io.Reader that includes any sniffed header bytes, and an error.

func EnsureAbsPath

func EnsureAbsPath(path string) string

EnsureAbsPath takes a clean path and forces it to be absolute. If it fails to get absolute path (rare), it checks if it's already absolute, otherwise relies on the input.

func IsLoggingEnabled added in v0.7.7

func IsLoggingEnabled() bool

IsLoggingEnabled returns true if debug logging is configured This allows callers to skip expensive argument evaluation

func Notify

func Notify(title, message string)

func OpenContainingFolder

func OpenContainingFolder(path string) error

func OpenFile

func OpenFile(path string) error

func ReadURLsFromFile

func ReadURLsFromFile(filepath string) ([]string, error)

ReadURLsFromFile reads URLs from a file. Accepts one URL per line or whitespace-separated URLs, and ignores comments. Trailing-slash-only variants are treated as the same URL so batch imports behave consistently across CLI and TUI entry points.

Types

This section is empty.

Jump to

Keyboard shortcuts

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