1

Fix linter warnings

This commit is contained in:
2020-02-22 18:33:33 +04:00
parent f30fb4dc67
commit fd184225f1
9 changed files with 35 additions and 3 deletions

View File

@@ -21,22 +21,28 @@ func login() {
// First enter is site name, second and third are user credentials
scanner := bufio.NewScanner(os.Stdin)
scanline := 0
for scanner.Scan() {
scanline++
switch {
case scanline == 1:
c.Config.URL = scanner.Text()
dlog.Info().Msg("Введите имя пользователя")
case scanline == 2:
c.Config.Username = scanner.Text()
dlog.Info().Msg("Введите пароль")
default:
c.Config.Password = scanner.Text()
}
if scanline == 3 {
break
}
}
if scanner.Err() != nil {
dlog.Fatal().Err(scanner.Err()).Msg("Не удалось прочитать пользовательский ввод.")
}
@@ -78,19 +84,23 @@ func obtainCookies() {
retryCount := 0
var resp *http.Response
var err error
for {
if retryCount == 10 {
dlog.Fatal().Err(err).Msg("Не удалось отправить запрос на авторизацию в NNM-Club.")
}
resp, err = client.Do(req)
if err != nil {
dlog.Debug().Err(err).Int("попытка", retryCount).Msg("Не удалось отправить запрос, попробуем ещё раз")
retryCount++
time.Sleep(2 * time.Second)
} else {
break
}
}
defer resp.Body.Close()
if len(resp.Cookies()) == 0 {