Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime error #742

Open
Hasi666 opened this issue Aug 3, 2024 · 1 comment
Open

Runtime error #742

Hasi666 opened this issue Aug 3, 2024 · 1 comment

Comments

@Hasi666
Copy link

Hasi666 commented Aug 3, 2024

for update := range updates {
    if update.Message != nil {
        text := update.Message.Text
        chatID := update.Message.Chat.ID
        if text == "/start" re.MatchString(text) text == "cancel" {
          match := re.FindStringSubmatch(text)
          referrerID, _ := strconv.Atoi(match[1])
          refral.StartHandler(bot, update, referrerID)
and ....

2024/08/03 11:33:54 Endpoint: getUpdates, params: map[allowed_updates:null offset:489227412 timeout:60]
**panic: runtime error: index out of range [1] with length 0

goroutine 1 [running]:
main.main()
        C:/Users/Afra/Desktop/main.go:39 +0x868
exit status 2**

How fix that and why it happend ?

@weezel
Copy link

weezel commented Oct 13, 2024

Without seeing the whole code it's a bit hard to say but here:

  • referrerID, _ := strconv.Atoi(match[1])
  • and on error **panic: runtime error: index out of range [1] with length 0
    => you are trying to access slice index 1 which doesn't exist. Actually length of that slice is 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants