stringutil

package
v0.7.3-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2025 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package stringutil provides string utility functions.

Index

Constants

View Source
const (
	PasswordDummy = "•"
)

Variables

This section is empty.

Functions

func ComputeRecipients

func ComputeRecipients(
	from, to, cc, bcc []string,
	contactEmail, inboxEmail string,
	lastMessageIncoming bool,
) (finalTo, finalCC, finalBCC []string)

ComputeRecipients computes new recipients using last message's recipients and direction.

func DedupAndExcludeString

func DedupAndExcludeString(list []string, exclude string) []string

DedupAndExcludeString returns a deduplicated []string excluding empty and a specific value.

func ExtractEmail

func ExtractEmail(s string) (string, error)

ExtractEmail extracts the email address from a string.

func FormatDuration

func FormatDuration(d time.Duration, includeSeconds bool) string

FormatDuration formats a duration as a string.

func GenerateEmailMessageID

func GenerateEmailMessageID(messageID string, fromAddress string) (string, error)

GenerateEmailMessageID generates a RFC-compliant Message-ID for an email, does not include the angle brackets. The client is expected to wrap the returned string in angle brackets.

func GetPathFromURL

func GetPathFromURL(u string) (string, error)

GetPathFromURL extracts the path from a URL.

func HTML2Text

func HTML2Text(html string) string

HTML2Text converts HTML to text.

func RandomAlphanumeric

func RandomAlphanumeric(n int) (string, error)

RandomAlphanumeric generates a random alphanumeric string of length n.

func RandomNumeric

func RandomNumeric(n int) (string, error)

RandomNumeric generates a random numeric string of length n.

func RemoveEmpty

func RemoveEmpty(s []string) []string

RemoveEmpty removes empty strings from a slice of strings.

func RemoveItemByValue

func RemoveItemByValue(slice []string, value string) []string

RemoveItemByValue removes all instances of a value from a slice of strings.

func ReverseSlice

func ReverseSlice(source []string)

ReverseSlice reverses a slice of strings in place.

func SanitizeFilename

func SanitizeFilename(fName string) string

SanitizeFilename sanitizes the provided filename.

func ValidEmail

func ValidEmail(email string) bool

ValidEmail returns true if it's a valid email else return false.

Types

This section is empty.

Jump to

Keyboard shortcuts

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