package domain func GetTargetURL(shortURL string) (target string, err error) { su := ShortURL{URL: URL(shortURL)} tu, err := shortURLRepository.GetTarget(su) if err != nil { target = "" } else { target = string(tu.URL) } return } func GetShortURL(targetURL string) (short string, isNew bool, err error) { tu := TargetURL{URL: URL(targetURL)} if tu.IsEmpty() { // Zero values are OK for short and isNew. err = MakeError(TargetInvalidError, "empty URL") return } su, isNew, err := targetURLRepository.GetShort(tu) if err == nil { short = string(su.URL) } return }