strutil

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2025 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddQueryParamToUrl

func AddQueryParamToUrl(url, key, value string) string

func CreatePath

func CreatePath(addLeadingSlash bool, parts ...string) string

CreatePath creates a path from the given parts.

If addLeadingSlash is true, a leading slash will be added to the path.

All colliding slashes will be converted to a single slash.

func FormatFileSize

func FormatFileSize(size int64) string

FormatFileSize pretty prints a file size (in bytes) to a human-readable format

e.g. 1024 -> 1 KB

func GetContentTypeFromFileName

func GetContentTypeFromFileName(fileName string) string

GetContentTypeFromFileName returns the content type of a file based on its file extension from the name.

If the file extension is not recognized, it returns "application/octet-stream".

func RemoveLeadingSlash

func RemoveLeadingSlash(str string) string

RemoveLeadingSlash removes the leading slash from a string.

func RemoveTrailingSlash

func RemoveTrailingSlash(str string) string

RemoveTrailingSlash removes the trailing slash from a string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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