Is the example working?
kokizzu opened this issue · comments
Kiswono Prayogo commented
I've tried the example from the README.md:
package main
import (
"fmt"
"log"
"github.com/buaazp/fasthttprouter"
"github.com/valyala/fasthttp"
)
func Index(ctx *fasthttp.RequestCtx) {
fmt.Fprint(ctx, "Welcome!\n")
}
func Hello(ctx *fasthttp.RequestCtx) {
fmt.Fprintf(ctx, "hello, %s!\n", ctx.UserValue("name"))
}
func main() {
router := fasthttprouter.New()
router.GET("/", Index)
router.GET("/hello/:name", Hello)
log.Fatal(fasthttp.ListenAndServe(":8080", router.Handler))
}
When I run it, it shows:
./test.go:21: cannot use Index (type func(*fasthttp.RequestCtx)) as type fasthttprouter.Handle in argument to router.GET
./test.go:22: cannot use Hello (type func(*fasthttp.RequestCtx)) as type fasthttprouter.Handle in argument to router.GET
Razon Yang commented
I guess that you are using the old version, please try the newest package.
Kiswono Prayogo commented
Ah you're right, I didn't notice..
$ go get -u -v github.com/buaazp/fasthttprouter
github.com/buaazp/fasthttprouter (download)
# cd /home/asd/go/src/github.com/buaazp/fasthttprouter; git pull --ff-only
fatal: Not possible to fast-forward, aborting.
package github.com/buaazp/fasthttprouter: exit status 128