utils

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2022 License: Unlicense Imports: 19 Imported by: 0

Documentation

Overview

Contains various utilities used throughout the program. Shouldn't depend on any other part of the program in order to avoid cyclic imports.

data.go, previously various files such as in.go, min.go, slicesEqual.go, etc. contains code for handling various types of data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(path string) error

Deletes a file.

func Err added in v1.1.0

func Err(err error, a ...string)

func Errs added in v1.2.1

func Errs(errs []error)

func GetBreadcrumbs

func GetBreadcrumbs(url string) ([]string, error)

func GetDoc

func GetDoc(url string) (*goquery.Document, error)

Gets the goquery document of a given web page.

func GetFileHash added in v1.1.0

func GetFileHash[T constraints.Integer](path string, bufSize T, hash hash.Hash) ([]byte, error)

func GetFileMD5 added in v1.1.0

func GetFileMD5[T constraints.Integer](path string, bufSize T) ([]byte, error)

func GetUpdated added in v1.1.0

func GetUpdated(url string) (string, error)

Gets the Updated timestamp

func In

func In[T comparable](slice []T, item T) bool

Checks if a slice of strings contains an given string.

func Info added in v1.1.0

func Info(msg string, a ...any)

func Min added in v1.1.0

func Min[T constraints.Ordered](a T, numbers ...T) T

Pass in any non-zero number of orderables and get back the one that's "smallest" (i.e. it < the rest).

Uses args `a` and `numbers` to ensure at least one value is given.

func MonthStrToInt added in v1.1.0

func MonthStrToInt(month string) time.Month

func ParseWorkshopTimestamp added in v1.1.0

func ParseWorkshopTimestamp(timestamp string) (time.Time, bool)

func Sanitise added in v1.3.1

func Sanitise[S ~string](str S) (string, error)

Replaces accents (e.g. 'é' -> 'e'). Converts to lowercase. Replaces whitespace with underscores. Removes all illegal characters.

func SlicesEqual added in v1.1.0

func SlicesEqual[T constraints.Ordered](a, b []T) bool

Checks if the items and order of two slices are equal

func Test added in v1.3.0

func Test()

used to check if i get up to a certain point

func Unzip

func Unzip(src, dest string) error

Based off of https://stackoverflow.com/a/24792688

func Warn added in v1.1.0

func Warn(warning string, a ...any)

func WorkshopIDFromURL added in v1.2.0

func WorkshopIDFromURL(url string) (int, error)

Extracts the Workshop ID from its URL.

func WorkshopIDToURL added in v1.2.0

func WorkshopIDToURL(id any) (string, bool)

Converts a Workshop ID to a Workshop URL

Types

This section is empty.

Jump to

Keyboard shortcuts

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