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

Converto type interface to int #15

Closed
araneta opened this issue Nov 15, 2016 · 5 comments · Fixed by #18
Closed

Converto type interface to int #15

araneta opened this issue Nov 15, 2016 · 5 comments · Fixed by #18

Comments

@araneta
Copy link

araneta commented Nov 15, 2016

I want to get integer value: var id = c.UserValue("id") but i got this error : cannot convert c.UserValue("id") (type interface {}) to type int: need type assertion
what should I do? Thanks

@araneta
Copy link
Author

araneta commented Nov 15, 2016

i can compile the code but i got this error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x476ce2]

goroutine 22 [running]:
panic(0x6e0ee0, 0xc4200120f0)
    /home/aldo/projects/go/go/src/runtime/panic.go:500 +0x1a1
github.com/heroku/go-getting-started/vendor/github.com/valyala/fasthttp.(*RequestCtx).SetUserValue(0x0, 0x7399b2, 0x2, 0x6caa60, 0xc42012eba0)
    /home/aldo/projects/go/go-simpeg-workspace/src/github.com/heroku/go-getting-started/vendor/github.com/valyala/fasthttp/server.go:461 +0x22
github.com/heroku/go-getting-started/vendor/github.com/buaazp/fasthttprouter.(*node).getValue(0xc42007ed70, 0xc42012eb9a, 0x1, 0x0, 0xc4201187e0, 0xc420098d00)
    /home/aldo/projects/go/go-simpeg-workspace/src/github.com/heroku/go-getting-started/vendor/github.com/buaazp/fasthttprouter/tree.go:364 +0x1c7
github.com/heroku/go-getting-started/vendor/github.com/buaazp/fasthttprouter.(*Router).allowed(0xc420069b00, 0xc42012eb90, 0xb, 0xc420038c50, 0x7, 0x7, 0x50)
    /home/aldo/projects/go/go-simpeg-workspace/src/github.com/heroku/go-getting-started/vendor/github.com/buaazp/fasthttprouter/router.go:273 +0x13d
github.com/heroku/go-getting-started/vendor/github.com/buaazp/fasthttprouter.(*Router).Handler(0xc420069b00, 0xc42013e000)
    /home/aldo/projects/go/go-simpeg-workspace/src/github.com/heroku/go-getting-started/vendor/github.com/buaazp/fasthttprouter/router.go:345 +0x509
github.com/heroku/go-getting-started/vendor/github.com/buaazp/fasthttprouter.(*Router).Handler-fm(0xc42013e000)
    /home/aldo/projects/go/go-simpeg-workspace/src/github.com/heroku/go-getting-started/main.go:64 +0x34
main.(*CORS).handler.func1(0xc42013e000)
    /home/aldo/projects/go/go-simpeg-workspace/src/github.com/heroku/go-getting-started/main.go:43 +0x137
github.com/heroku/go-getting-started/vendor/github.com/valyala/fasthttp.(*Server).serveConn(0xc42009ab40, 0x897c40, 0xc42007a0a0, 0x1, 0x101)
    /home/aldo/projects/go/go-simpeg-workspace/src/github.com/heroku/go-getting-started/vendor/github.com/valyala/fasthttp/server.go:1533 +0x573
github.com/heroku/go-getting-started/vendor/github.com/valyala/fasthttp.(*Server).(github.com/heroku/go-getting-started/vendor/github.com/valyala/fasthttp.serveConn)-fm(0x897c40, 0xc42007a0a0, 0xc420027f58, 0x1)
    /home/aldo/projects/go/go-simpeg-workspace/src/github.com/heroku/go-getting-started/vendor/github.com/valyala/fasthttp/server.go:1250 +0x3e
github.com/heroku/go-getting-started/vendor/github.com/valyala/fasthttp.(*workerPool).workerFunc(0xc420094480, 0xc420132240)
    /home/aldo/projects/go/go-simpeg-workspace/src/github.com/heroku/go-getting-started/vendor/github.com/valyala/fasthttp/workerpool.go:210 +0xde
github.com/heroku/go-getting-started/vendor/github.com/valyala/fasthttp.(*workerPool).getCh.func1(0xc420094480, 0xc420132240, 0x6bd020, 0xc420132240)
    /home/aldo/projects/go/go-simpeg-workspace/src/github.com/heroku/go-getting-started/vendor/github.com/valyala/fasthttp/workerpool.go:182 +0x35
created by github.com/heroku/go-getting-started/vendor/github.com/valyala/fasthttp.(*workerPool).getCh
    /home/aldo/projects/go/go-simpeg-workspace/src/github.com/heroku/go-getting-started/vendor/github.com/valyala/fasthttp/workerpool.go:184 +0x111

for this router router.DELETE("/religion/:relid", routes.DeleteReligion)

@palestamp
Copy link

+1 Same issue.

@buaazp
Copy link
Owner

buaazp commented Dec 2, 2016

Strange panic, I need more logs to find the reason, can you add one log line in fasthttprouter/tree.go at line 366 like this:

log.Printf("n.path: %d path: %d", len(n.path), len(path))
ctx.SetUserValue(n.path[1:], path[:end])

And catch the next panic log for me.

@palestamp
Copy link

Hi! This situation can be reproduced if you will send request with wrong method:

 router.PUT("/ua/v1/views/:action_type/:account_id/:post_id", self.putViewPoint)
 router.GET("/ua/v1/views", self.getViewPoints)

This will cause a panic:

 curl -XGET 'http://127.0.0.1/ua/v1/views/view/1233/234'

So the problem is in call to node.getValue with nil RequestCtx from Router.allowed method

@buaazp
Copy link
Owner

buaazp commented Dec 13, 2016

@palestamp Great job!

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

Successfully merging a pull request may close this issue.

3 participants