util

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download

func Download(id, file string, dl FileDownload) error

func ExpandUUID

func ExpandUUID(uuid string) string

ExpandUUID takes a uuid in the form without dashes, such as `aceb326fda1545bcbf2f11940c21780c` and returns it with dashes, eg `aceb326f-da15-45bc-bf2f-11940c21780c`.

If the uuid is already expanded, it will be returned as is. If the UUID is invalid, panic.

func IsUUID

func IsUUID(uuid string) bool

IsUUID checks if a given string is a valid UUID (expanded or trimmed)

func ReadFile

func ReadFile(file string, ptr interface{}) error

func ReadOrDownload

func ReadOrDownload(id, file string, dl FileDownload, ptr interface{}) error

func TrimUUID

func TrimUUID(uuid string) string

TrimUUID takes a uuid in the form with dashes, such as `aceb326f-da15-45bc-bf2f-11940c21780c` and returns it without dashes, eg `aceb326fda1545bcbf2f11940c21780c`.

If the uuid is already trimmed, it will be returned as is. If the UUID is invalid, panic.

Types

type FileDownload

type FileDownload struct {
	Sha1 string `json:"sha1"`
	Size int64  `json:"size"`
	Url  string `json:"url"`
}

Jump to

Keyboard shortcuts

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