Fix linter warnings
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user