package domain import ( "github.com/nicksnyder/go-i18n/v2/i18n" ) func GetTargetURL(shortURL string, localizer *i18n.Localizer) (target string, err error) { su := ShortURL{URL: URL(shortURL)} tu, err := shortURLRepository.GetTarget(su, localizer) if err != nil { target = "" } else { target = string(tu.URL) } return } func GetShortURL(targetURL string, localizer *i18n.Localizer) (short string, isNew bool, err error) { tu := TargetURL{URL: URL(targetURL)} if tu.IsEmpty() { // Zero values are OK for short and isNew. err = MakeError(localizer, TargetInvalid.ID, "empty URL") return } su, isNew, err := targetURLRepository.GetShort(tu) if err == nil { short = string(su.URL) } return }