arimelody.me/global/data.go

50 lines
809 B
Go
Raw Normal View History

package global
import (
"os"
"arimelody.me/arimelody.me/music/model"
"github.com/jmoiron/sqlx"
)
var HTTP_DOMAIN = func() string {
envvar := os.Getenv("HTTP_DOMAIN")
if envvar != "" {
return envvar
}
return "https://arimelody.me"
}
var DB *sqlx.DB
var Releases []*model.Release
var Artists []*model.Artist
var Tracks []*model.Track
func GetRelease(id string) *model.Release {
for _, release := range Releases {
if release.ID == id {
return release
}
}
return nil
}
func GetArtist(id string) *model.Artist {
for _, artist := range Artists {
if artist.ID == id {
return artist
}
}
return nil
}
func GetTrack(id string) *model.Track {
for _, track := range Tracks {
if track.ID == id {
return track
}
}
return nil
}