func importCountries(conn *transaction.Connection, config model.YAMLCountries) (err error) { log.Info("Import countries started") if err = conn.RemoveCountriesTranslations(); err != nil { return } for countryCode, country := range config.Countries { if conn.IsCountryExist(countryCode) == false { err = errors.New("Missing country") break } errorInsideTranslation := false for languageCode, translation := range country.Translations { if conn.IsLanguageExist(languageCode) == false { errorInsideTranslation = true err = errors.New("No language") break } if err = conn.CreateCountryTranslation(countryCode, languageCode, translation); err != nil { errorInsideTranslation = true break } } if errorInsideTranslation == true { break } } log.Info("Import countries finished") return }