github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/detail/details.go (about) 1 /* For license and copyright information please see LEGAL file in repository */ 2 3 package detail 4 5 import ( 6 "github.com/GeniusesGroup/libgo/protocol" 7 ) 8 9 type DetailsContainer struct { 10 detail map[protocol.LanguageID]protocol.Detail 11 details []protocol.Detail 12 } 13 14 func (d *DetailsContainer) Details() []protocol.Detail { return d.details } 15 func (d *DetailsContainer) Detail(lang protocol.LanguageID) protocol.Detail { 16 return d.detail[lang] 17 } 18 19 // SetDetail add error text details to existing error and return it. 20 func (d *DetailsContainer) SetDetail(lang protocol.LanguageID, domain, summary, overview, userNote, devNote string, tags []string) { 21 var _, ok = d.detail[lang] 22 if ok { 23 panic("detail - Can't change detail after first set! Ask the holder to change details.") 24 } 25 26 var detail = Detail{ 27 languageID: lang, 28 domain: domain, 29 summary: summary, 30 overview: overview, 31 userNote: userNote, 32 devNote: devNote, 33 tags: tags, 34 } 35 if d.detail == nil { 36 d.detail = make(map[protocol.LanguageID]protocol.Detail) 37 } 38 d.detail[lang] = &detail 39 d.details = append(d.details, &detail) 40 }