package model import ( "html/template" "strings" ) type ( Track struct { ID string `json:"id"` Title string `json:"title"` Description string `json:"description"` Lyrics string `json:"lyrics" db:"lyrics"` PreviewURL string `json:"previewURL" db:"preview_url"` } DisplayTrack struct { *Track Lyrics template.HTML `json:"lyrics"` Number int `json:"-"` } ) func (track Track) MakeDisplay(number int) DisplayTrack { return DisplayTrack{ Track: &track, Lyrics: template.HTML(strings.Replace(track.Lyrics, "\n", "
", -1)), Number: number, } }