Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Help 

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

When I run my program written that was written in Go the following error occurs:

Code
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x605acf]

goroutine 19 [running]:
net/http/cookiejar.(*Jar).cookies(0x0, 0xc0001062d0, {0x20, 0x0, 0x8872e0})
        /usr/local/go/src/net/http/cookiejar/jar.go:168 +0x14f
net/http/cookiejar.(*Jar).Cookies(0x68f71d, 0x5aea9e)
        /usr/local/go/src/net/http/cookiejar/jar.go:156 +0x3d
building-detroit-bot/req.updateCookies(0x7f2504670ed8, 0xc000106240)
        /root/safe/tools/team-seas/req/post.go:41 +0x65
building-detroit-bot/req.MakePost(0xc000108000, {0xc0000e4100, 0x72}, {0xc0000cc078, 0x17}, 0xc0000adbf0, 0x0)
        /root/safe/tools/team-seas/req/post.go:35 +0x50e
building-detroit-bot/api/ids.GetIDs({0xc0000e4100, 0x72}, {0xc0000cc078, 0x17})
        /root/safe/tools/team-seas/api/ids/get.go:33 +0x185
main.work(0x0, 0x5, 0x1)
        /root/safe/tools/team-seas/main.go:45 +0x1d8
created by main.main
        /root/safe/tools/team-seas/main.go:89 +0x337

The updateCookies function looks like this:

Code
func updateCookies(jar *cookiejar.Jar, res *http.Response) {
        u, _ := url.Parse(endpoints.TokensURL)
        cookies := jar.Cookies(u)
        for _, cookie := range res.Cookies() {
                c := &http.Cookie{
                        Name:   cookie.Name,
                        Value:  cookie.Value,
                        Path:   cookie.Path,
                        Domain: cookie.Domain,
                }
                cookies = append(cookies, c)
                fmt.Println("Cookie:", cookie.Name, "=", cookie.Value)
        }
        jar.SetCookies(u, cookies)
}

I am new to Go and need to fix this error, what is a solution for this problem?


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Help] by EuropeApr 7, 2023 08:41 PM 13 435 Apr 7, 2023 08:41 PM
Last Post: oRequiem
[Assembly] by UiqueblhatsAug 7, 2017 03:52 AM 9 527 Aug 7, 2017 03:52 AM
Last Post: IllegalSkills
[Delphi] by invocker49Jun 1, 2017 06:37 PM 1 367 Jun 1, 2017 06:37 PM
Last Post: collisionpacker