Repository: Arriven/db1000n
File: main.go (Go)

Code before:
	var backupConfig string
	var refreshTimeout time.Duration
	var logLevel logs.Level
	var help bool
	var metricsPath string
	flag.StringVar(&configPath, "c", "https://raw.githubusercontent.com/db1000n-coordinators/LoadTestConfig/main/config.json", "path to config files, separated by a comma, each path can be a web endpoint")
	flag.StringVar(&backupConfig, "b", utils.DefaultConfig, "raw backup config in case the primary one is unavailable")
	flag.DurationVar(&refreshTimeout, "r", time.Minute, "refresh timeout for updating the config")
	flag.IntVar(&logLevel, "l", logs.Info, "logging level. 0 - Debug, 1 - Info, 2 - Warning, 3 - Error")
	flag.BoolVar(&help, "h", false, "print help message and exit")
	flag.StringVar(&metricsPath, "m", "", "path where to dump usage metrics, can be URL or file, empty to disable")
	flag.Parse()
	if help {
		flag.CommandLine.Usage()
		return
	}

	l := logs.New(logLevel)
	clientID := uuid.New().String()
	
	resp, err := http.Get("https://api.myip.com/")
	if err != nil {
		l.Warning("Can't check users country. Please manually check that VPN is enabled or that you have non Ukrainian IP adress.")
	} else {
		body, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			l.Warning("Can't check users country. Please manually check that VPN is enabled or that you have non Ukrainian IP adress.")
		} else {
			ipInfo := IPInfo{}
			err = json.Unmarshal(body, &ipInfo)
			if err != nil{
				l.Warning("Can't check users country. Please manually check that VPN is enabled or that you have non Ukrainian IP adress.")
			} else {
				if (ipInfo.Country == "Ukraine") {
					l.Error("You currently have Ukrainian IP adress. You need to enable VPN.")
					// TODO add correct URL
					//openBrowser("https://example.com/", l)
				} else {
					l.Info("Current country: %s", ipInfo.Country)
				}
			}

		}
	}

	var cancel context.CancelFunc
	defer func() {
		cancel()
	}()

	for {

Review comment (suggestion):
```suggestion
                defer resp.Body.Close()
		body, err := ioutil.ReadAll(resp.Body)
```

Code after:
	var backupConfig string
	var refreshTimeout time.Duration
	var logLevel logs.Level
	var help bool
	var metricsPath string
	flag.StringVar(&configPath, "c", "https://raw.githubusercontent.com/db1000n-coordinators/LoadTestConfig/main/config.json", "path to config files, separated by a comma, each path can be a web endpoint")
	flag.StringVar(&backupConfig, "b", utils.DefaultConfig, "raw backup config in case the primary one is unavailable")
	flag.DurationVar(&refreshTimeout, "r", time.Minute, "refresh timeout for updating the config")
	flag.IntVar(&logLevel, "l", logs.Info, "logging level. 0 - Debug, 1 - Info, 2 - Warning, 3 - Error")
	flag.BoolVar(&help, "h", false, "print help message and exit")
	flag.StringVar(&metricsPath, "m", "", "path where to dump usage metrics, can be URL or file, empty to disable")
	flag.Parse()
	if help {
		flag.CommandLine.Usage()
		return
	}

	l := logs.New(logLevel)
	clientID := uuid.New().String()
	
	resp, err := http.Get("https://api.myip.com/")
	if err != nil {
		l.Warning("Can't check users country. Please manually check that VPN is enabled or that you have non Ukrainian IP adress.")
	} else {
                defer resp.Body.Close()
		body, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			l.Warning("Can't check users country. Please manually check that VPN is enabled or that you have non Ukrainian IP adress.")
		} else {
			ipInfo := IPInfo{}
			err = json.Unmarshal(body, &ipInfo)
			if err != nil{
				l.Warning("Can't check users country. Please manually check that VPN is enabled or that you have non Ukrainian IP adress.")
			} else {
				if (ipInfo.Country == "Ukraine") {
					l.Error("You currently have Ukrainian IP adress. You need to enable VPN.")
					// TODO add correct URL
					//openBrowser("https://example.com/", l)
				} else {
					l.Info("Current country: %s", ipInfo.Country)
				}
			}

		}
	}

	var cancel context.CancelFunc
	defer func() {
		cancel()
	}()