Questions tagged [panic]

A condition of the the operating system when its state is so broken that imminent shutdown is preferred.

A condition of the the operating system when its state is so broken that imminent shutdown is preferred. This may be caused by hardware failure but is also frequently caused by various kernel bugs, driver bugs, misconfigurations and attempts to use incompatible modules.

It often would be possible to continue the work of the operating system in this condition but this could result the data loss. Hence the shutdown is preferred.

279 questions
-3
votes
1 answer

golang runtime error: index out of range

I have a simple for loop in go which iterates through a slice of integers and changes the position of the current if next is smaller basically a sort, but it keeps showing me this error which says panic: runtime error: index out of range Here is…
Jul Kreshpaj
  • 29
  • 1
  • 7
-3
votes
2 answers

Not catching second return value in type assertion causes runtime panic

Below code causes runtime panic on second Println if assertion fails and second value "OK" is not provided for assignment for return value. however, if the second value is provided runtime panic does not occur. How not assigning return value can…
Akshay Naik
  • 669
  • 1
  • 6
  • 22
-3
votes
2 answers

Error in code. Lua on NodeMCU

I have a motorized roller blind project. I am following this instructable: https://www.instructables.com/id/Motorized-WiFi-IKEA-Roller-Blind/ . I am using the code in the instructable, but I suspect tha fault is in one of these codes: config.lua --…
petrepa
  • 13
  • 1
  • 5
-4
votes
1 answer

How to make strings take negative indexes without reporting errors

When I try to solve an algorithm problem, I find that my golang code needs to take the negative index of the string, which generates an error, so what do I do? func FindLongestPalindrom(s string) string { if len(s) == 1 || s == reverseString(s)…
pl5020
  • 1
-4
votes
1 answer

Even checking the right condition Go throwing, panic: runtime error: index out of range [3] with length 3

package main import "fmt" func mergeSortedArray(arr1 []int, arr2 []int) []int { var mergedArr []int lengthArr := len(arr1) + len(arr2) fmt.Println(lengthArr) i := 0 j := 0 //Check input if len(arr1) == 0 { …
Alok Tripathi
  • 874
  • 10
  • 9
-4
votes
1 answer

Panic/error while inserting a value into a map

I have the following code : package main import "fmt" type config struct { user string pass string B map[string]int } func main() { conf := new(config) conf.user = "florence" conf.pass = "machine" // …
jsor
  • 97
  • 5
-4
votes
1 answer

Go - runtime error: invalid memory address or nil pointer dereference

I am trying to use Go to make a proxy server which changes certain values in the body of a request to an API however when the request is sent the following panic occurs and the request fails: 2015/05/03 14:17:52 http: panic serving…
bshaw
  • 13
  • 1
  • 4
-4
votes
1 answer

How to check if Scanln throws an error in Golang

I am new to Go. I've been searching for answers and I know there really is one I just haven't found it. To better explain my question, here is my code: func main() { ... inputs := new(Inputs) fmt.Println("Input two numbers: ") …
symfonian
  • 33
  • 7
-5
votes
2 answers

I've started a panic with my index out of range, and I can't get out

I'm writing this program to become comfortable with types (not objects!). The basic premise is the user enters an animal name (cow, snake bird), then an action (eat, move, sound.) My code then looks it up and returns the value. So, the user entry is…
Ezra Greene
  • 27
  • 1
  • 7
1 2 3
18
19