util

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Copyright © 2024 Alessandro Riva

Licensed under the MIT License. See the LICENSE file for details.

Licensed under the MIT License. See the LICENSE file for details.

Licensed under the MIT License. See the LICENSE file for details.

Index

Constants

This section is empty.

Variables

View Source
var (
	IPRegex      = regexp.MustCompile(`\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b`)
	RFC1918Regex = regexp.MustCompile(`^(10\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.(1[6-9]|2[0-9]|3[0-1])\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3})$`)
	URLRegex     = regexp.MustCompile(`https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)`)
	EmailRegex   = regexp.MustCompile(`[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}`)
	DomainRegex  = regexp.MustCompile(`(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+(?:[a-zA-Z]{2,})|localhost)`)
	SHA256Regex  = regexp.MustCompile(`\b[a-fA-F0-9]{64}\b`)
)

Functions

func GetPromptedInput

func GetPromptedInput(prompt string) string

getPromptedInput prompts the user for input if the standard input is not a pipe

func HumanReadableDate

func HumanReadableDate(dateString string) (string, error)

func IsValidDomain

func IsValidDomain(domain string) bool

func PrintEntry

func PrintEntry(entryName string, entryValue interface{})

func PrintError

func PrintError(format string, a ...interface{})

func PrintHeader

func PrintHeader(format string, a ...interface{})

func PrintSuccess

func PrintSuccess(format string, a ...interface{})

func PrintWarning

func PrintWarning(format string, a ...interface{})

func PrintYesNo

func PrintYesNo(val bool) string

func RemoveDuplicates

func RemoveDuplicates(items []string) []string

Remove duplicates from a slice

func ShortStr

func ShortStr(s string, maxLength int) string

Shorten string to given length

Types

This section is empty.

Jump to

Keyboard shortcuts

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