utils

package
v0.22.0-beta Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const JSON = "json"
View Source
const XML = "xml"
View Source
const YAML = "yaml"

Variables

This section is empty.

Functions

func CreateDir

func CreateDir(dirPath string) error

func DetectContentType

func DetectContentType(content []byte) (string, error)

detects JSON/YAML content type. returns error if no match is found

func FindAllString

func FindAllString(re *regexp2.Regexp, s string) []string

func InferContentTypeByPath

func InferContentTypeByPath(filename string) (string, error)

Infer content type based on URI/file path

func LoadJsonYaml

func LoadJsonYaml(filedata []byte, holder any, contentType string) error

Parses JSON/YAML file content into holder ptr based on contentType

func LoadJsonYamlFromFile

func LoadJsonYamlFromFile(filename string, holder any, contentType string) error

Loads JSON/YAML file into holder ptr based on contentType Note: function assumes that user has already validated filename

func RemoveElement

func RemoveElement[T comparable](slice []T, element T) []T

func SearchInSlice

func SearchInSlice[T comparable](slice []T, element T) bool

func SearchStringInSlice

func SearchStringInSlice(strings []string, search string) bool

Function to search for a string in a slice of strings

func ValidateURL

func ValidateURL(u string) bool

ValidateURL checks if the provided URL is valid. Note it doesn't make request to the server.

func WriteFile

func WriteFile(filePath string, data []byte) error

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳