-- 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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to