Documentation
¶
Index ¶
- func CopyFile(src, dst string) (err error)
- func DateRange(week, month, year int) (time.Time, time.Time, error)
- func FlattenAliases(aliases []models.Alias) []string
- func FlattenArtistIDs(artists []*models.Artist) []int32
- func FlattenArtistMbzIDs(artists []*models.Artist) []uuid.UUID
- func FlattenArtistNames(artists []*models.Artist) []string
- func FlattenMbzArtistCreditNames(artists []mbz.MusicBrainzArtistCredit) []string
- func FlattenSimpleArtistNames(artists []models.SimpleArtist) []string
- func GenerateRandomString(length int) (string, error)
- func IDFromString(s string) string
- func MoreThanOneString(s ...string) bool
- func MoveFirstMatchToFront(slice []string, substring string) []string
- func ParseBool(s string) (value, ok bool)
- func ParseUUIDSlice(str []string) ([]uuid.UUID, error)
- func RemoveInBoth(s, c []string) []string
- func RemoveNonAscii(s []string) []string
- func Unique(xs *[]string)
- func UniqueIgnoringCase(s []string) []string
- func WriteError(w http.ResponseWriter, message string, code int)
- func WriteJSON(w http.ResponseWriter, status int, data any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyFile ¶
CopyFile copies a file from src to dst. If src and dst files exist, and are the same, then return success. Otherise, attempt to create a hard link between the two files. If that fail, copy the file contents from src to dst.
func DateRange ¶
DateRange takes optional week, month, and year. If all are 0, it returns the zero time range. If only year is provided, it returns the full year. If both month and year are provided, it returns the start and end of that month. If week and year are provided, it returns the start and end of that week. If only week or month is provided without a year, it's considered invalid.
func FlattenAliases ¶
func FlattenArtistIDs ¶
func FlattenArtistNames ¶
func FlattenMbzArtistCreditNames ¶
func FlattenMbzArtistCreditNames(artists []mbz.MusicBrainzArtistCredit) []string
func FlattenSimpleArtistNames ¶
func FlattenSimpleArtistNames(artists []models.SimpleArtist) []string
func GenerateRandomString ¶
Taken with little modification from https://gist.github.com/dopey/c69559607800d2f2f90b1b1ed4e550fb?permalink_comment_id=3527095#gistcomment-3527095
func IDFromString ¶
func MoreThanOneString ¶
Returns true if more than one string is not empty
func MoveFirstMatchToFront ¶
MoveFirstMatchToFront moves the first string containing the substring to the front of the slice.
func RemoveInBoth ¶
Returns only items that are in one slice but not the other
func RemoveNonAscii ¶
Returns the same slice, but with all entries that contain non ASCII characters removed
func UniqueIgnoringCase ¶
Returns the same slice, but with all strings that are equal (with strings.EqualFold) included only once
func WriteError ¶
func WriteError(w http.ResponseWriter, message string, code int)
Essentially the same as utils.WriteError(w, `{"error": "message"}`, code)
Types ¶
This section is empty.