It give error missing return at end of function
. I've tried add return nil
, return ""
, return c.String
, and several others but none works.
package main
import (
"github.com/hiteshmodha/goDevice"
"github.com/labstack/echo"
"net/http"
)
func main() {
e := echo.New()
e.Get("/", func(c *echo.Context, w http.ResponseWriter, r *http.Request) *echo.HTTPError {
deviceType := goDevice.GetType(r)
if deviceType == "Mobile" {
return c.String(http.StatusOK, "Mobile!")
} else if deviceType == "Web" {
return c.String(http.StatusOK, "Desktop!")
} else if deviceType == "Tab" {
return c.String(http.StatusOK, "Tablet!")
}
})
e.Run(":4444")
}
This one quite different that other case such as in here.
Without framework, it works fine.