anchor

package module
v0.0.0-...-31a7b77 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2025 License: MIT Imports: 5 Imported by: 16

README

= anchor
Matt Nicholls <transientvariable@protonmail.com>
:keywords: golang,anchor
:experimental: true
:icons: font
:iconfont-cdn: //cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.1.1/css/fontawesome.min.css
:imagesdir: docs/image
:sectanchors: true
:source-highlighter: prettify

ifdef::env-github[]
:tip-caption: :bulb:
:note-caption: :information_source:
:important-caption: :heavy_exclamation_mark:
:caution-caption: :fire:
:warning-caption: :warning:
endif::[]


== Overview

Miscellaneous reusable components in Go used by other modules.

== Installation

.Prerequisites
* The link:https://golang.org/dl/[Golang Runtime], version 1.24.x or later

[source%nowrap,bash]
----
❯ go get -u github.com/transientvariable/anchor
----

== License
This project is licensed under the link:LICENSE[MIT License].

Documentation

Index

Constants

View Source
const (
	// SI size units
	KB = 1000
	MB = 1000 * KB
	GB = 1000 * MB
	TB = 1000 * GB
	PB = 1000 * TB

	// IEC size units
	KiB = 1024
	MiB = 1024 * KiB
	GiB = 1024 * MiB
	TiB = 1024 * GiB
	PiB = 1024 * TiB
)

Variables

View Source
var (
	EmailPattern       *regexp.Regexp
	IPv4Pattern        *regexp.Regexp
	StoragePathPattern *regexp.Regexp
	URISchemePattern   *regexp.Regexp
	UsernamePattern    *regexp.Regexp
)

Functions

func RemoveWhitespace

func RemoveWhitespace(s string) string

RemoveWhitespace removes all whitespace characters from the provided string.

func ToJSON

func ToJSON(source any) json.RawMessage

ToJSON serializes the provided source value to a raw JSON byte sequence, which can be cast to a string to get the text representation. If an error occurs during serialization, the error message is serialized to JSON, e.g. `{"error": "error message..."}`.

func ToJSONFormatted

func ToJSONFormatted(source any) json.RawMessage

ToJSONFormatted performs the same function as ToJSON and applies formatting to make the result more human-readable.

func Unique

func Unique[S comparable](values ...S) []S

Unique returns the slice containing the unique values from the provided slice.

Types

This section is empty.

Directories

Path Synopsis
net

Jump to

Keyboard shortcuts

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