Please describe the error you are getting. (I suspect this me yet-another “go 
run”-episode)

It seems you are trying to do MVC the ASP.NET <http://asp.net/> way in Go - I’m 
quite confident that this will not give a good result.

I’ve been down a similar route (pun intended) when I started programming Go and 
found that going with the least amount of code was the right way. I recommend 
you try using the default HTTP routing from the std lib.

-- 
Michael Banzon
https://michaelbanzon.com/




> Den 23. nov. 2017 kl. 05.37 skrev Teo <thanhsang.d...@urekamedia.vn>:
> 
> -- Blog
> -----|---Controllers
> ---------------|-----------Backend
> -------------------------------|--------index_controller.go
> ---------------|-----------Frontend
> -------------------------------|--------index_controller.go
> 
> -----|-main.go
> 
> 
> /// file main.go 
> 
> package main
> 
> import (
>     "net/http"
> 
>     "./controllers/backend"
>     "./controllers/frontend"
>     "github.com/julienschmidt/httprouter"
> )
> 
> func main() {
>     frontend := &frontend.IndexFrontend{}
>     backend := &backend.IndexBackend{}
>     router := httprouter.New()
> 
>     router.GET("/", frontend.Index)
> 
>     router.GET("/admin", backend.Index)
> 
>     http.ListenAndServe("localhost:8080", router)
> }
> 
> // frontend / index_controller.go
> 
> package frontend
> 
> import (
>     "fmt"
>     "net/http"
> )
> 
> type IndexFrontend struct {
> }
> 
> func (c *IndexFrontend) Index(w http.ResponseWriter, r *http.Request) {
>     fmt.Println("frontend")
> }
> 
> // backend / index_controller.go
> 
> package backend
> 
> import (
>     "fmt"
>     "net/http"
> )
> 
> type Indexbackend struct {
> }
> 
> func (c *Indexbackend) Index(w http.ResponseWriter, r *http.Request) {
>     fmt.Println("backend")
> }
> 
> 
> go run main.go ==> error 
> 
> Help me code golang? thanks all
> 
> 
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com 
> <mailto:golang-nuts+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to