package
1.24.0-dev
Repository: https://github.com/go-gitea/gitea.git
Documentation: pkg.go.dev

# Packages

# Functions

AESGCMDecrypt (from legacy package): decrypts ciphertext with the given key using AES in GCM mode.
AESGCMEncrypt (from legacy package): encrypts plaintext with the given key using AES in GCM mode.
CommonSkip will check a provided name to see if it represents file or directory that should not be watched.
ContrastColor returns a black or white foreground color that the highest contrast ratio.
CopyFile copies file from source to target path.
CreatePublicKeyFingerprint creates a fingerprint of the given key.
CryptoRandomBytes generates `length` crypto bytes This differs from CryptoRandomString, as each byte in CryptoRandomString is generated by [0,61] range This function generates totally random bytes, each byte is generated by [0,255] range.
CryptoRandomInt returns a crypto random integer between 0 and limit, inclusive.
CryptoRandomString generates a crypto random alphanumerical string, each byte is generated by [0,61] range.
FilePathJoinAbs joins the path elements into a single file path, each element is cleaned by filepath.Clean separately.
FileURLToPath extracts the path information from a file://..
GenerateKeyPair generates a public and private keypair.
GetRelativeLuminance returns relative luminance for a SRGB color - https://en.wikipedia.org/wiki/Relative_luminance Keep this in sync with web_src/js/utils/color.js.
HexToRBGColor parses color as RGB values in 0..255 range from the hex color string (with or without #).
HomeDir returns path of '~'(in Linux) on Windows, it returns error when the variable does not exist.
IfZero returns "def" if "v" is a zero value, otherwise "v".
Iif is an "inline-if", it returns "trueVal" if "condition" is true, otherwise "falseVal".
IsDir returns true if given path is a directory, or returns false when it's a file or does not exist.
IsEmptyReader reads a reader and ensures it is empty.
IsEmptyString checks if the provided string is empty.
IsExist checks whether a file or directory exists.
IsFile returns true if given path is a file, or returns false when it's a directory or does not exist.
IsReadmeFileExtension reports whether name looks like a README file based on its name.
IsReadmeFileName reports whether name looks like a README file based on its name.
TODO: Replace with "maps.Keys" once available, current it only in golang.org/x/exp/maps but not in standard library.
NewAlreadyExistErrorf returns an error that formats as the given text but unwraps as an ErrAlreadyExist.
NewInvalidArgumentErrorf returns an error that formats as the given text but unwraps as an ErrInvalidArgument.
NewNotExistErrorf returns an error that formats as the given text but unwraps as an ErrNotExist.
NewPermissionDeniedErrorf returns an error that formats as the given text but unwraps as an ErrPermissionDenied.
NewSilentWrapErrorf returns an error that formats as the given text but unwraps as the provided error.
NormalizeEOL will convert Windows (CRLF) and Mac (CR) EOLs to UNIX (LF).
OptionalArg helps the "optional argument" in Golang: func foo(optArg ...int) { return OptionalArg(optArg) } calling `foo()` gets zero value 0, calling `foo(100)` gets 100 func bar(optArg ...int) { return OptionalArg(optArg, 42) } calling `bar()` gets default value 42, calling `bar(100)` gets 100 Passing more than 1 item to `optArg` or `defaultValue` is undefined behavior.
OptionalBoolParse get the corresponding optional.Option[bool] of a string using strconv.ParseBool.
PackData uses gob to encode the given data in sequence.
PaginateSlice cut a slice as per pagination options if page = 0 it do not paginate.
PathEscapeSegments escapes segments of a path while not escaping forward slash.
PathJoinRel joins the path elements into a single path, each element is cleaned by path.Clean separately.
PathJoinRelX joins the path elements into a single path like PathJoinRel, and covert all backslashes to slashes.
ReadAtMost reads at most len(buf) bytes from r into buf.
ReadWithLimit reads at most "limit" bytes from r into buf.
Remove removes the named file or (empty) directory with at most 5 attempts.
RemoveAll removes the named file or (empty) directory with at most 5 attempts.
Rename renames (moves) oldpath to newpath with at most 5 attempts.
SanitizeCredentialURLs remove all credentials in URLs (starting with "scheme://") for the input string: "https://user:[email protected]" => "https://[email protected]".
SanitizeErrorCredentialURLs wraps the error and make sure the returned error message doesn't contain sensitive credentials in URLs.
SecToTime converts an amount of seconds to a human-readable string.
ShellEscape will escape the provided string.
SliceContainsString sequential searches if string exists in slice.
SliceRemoveAll removes all the target elements from the slice.
SliceSortedEqual returns true if the two slices will be equal when they get sorted.
Sorted returns the sorted slice Note: The parameter is sorted inline.
SplitStringAtByteN splits a string at byte n accounting for rune boundaries.
SplitTrimSpace splits the string at given separator and trims leading and trailing space.
StatDir gathers information of given directory by depth-first.
ToFloat64 transform a given int into float64.
ToInt64 transform a given int into int64.
ToPointer returns the pointer of a copy of any given value.
ToSnakeCase convert the input string to snake_case format.
ToTitleCase returns s with all english words capitalized.
ToTitleCaseNoLower returns s with all english words capitalized without lower-casing.
ToUpperASCII returns s with all ASCII letters mapped to their upper case.
UnpackData uses gob to decode the given data in sequence.
UnsafeBytesToString uses Go's unsafe package to convert a byte slice to a string.
UnsafeStringToBytes uses Go's unsafe package to convert a string to a byte slice.
URLJoin joins url components, like path.Join, but preserving contents.
TODO: Replace with "maps.Values" once available, current it only in golang.org/x/exp/maps but not in standard library.

# Variables

Common Errors forming the base of our error system Many Errors returned by Gitea can be tested against these errors using errors.Is.
Common Errors forming the base of our error system Many Errors returned by Gitea can be tested against these errors using errors.Is.
ErrNotEmpty is an error reported when there is a non-empty reader.
Common Errors forming the base of our error system Many Errors returned by Gitea can be tested against these errors using errors.Is.
Common Errors forming the base of our error system Many Errors returned by Gitea can be tested against these errors using errors.Is.

# Structs

SilentWrap provides a simple wrapper for a wrapped error where the wrapped error message plays no part in the error message Especially useful for "untyped" errors created with "errors.New(…)" that can be classified as 'invalid argument', 'permission denied', 'exists already', or 'does not exist'.