Answer the question
In order to leave comments, you need to log in
Why does not see the functions in the package?
Here is main.go code
package main
import (
"generais/kontroller"
"github.com/julienschmidt/httprouter"
"log"
"net/http"
)
func main() {
router := httprouter.New()
router.GET("/", kontroller.formEcho)
router.POST("/form_handler", kontroller.formPost)
log.Fatal(http.ListenAndServe(":8080", router))
}
package kontroller
import (
"fmt"
"github.com/julienschmidt/httprouter"
"net/http"
)
func formEcho(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
fmt.Fprint(w, "<html><body><form action='http://localhost:8080/form_handler' method='POST'><input type='text' name='some_input'></form></body></html>")
}
func formPost(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
some_input := r.PostFormValue("some_input")
fmt.Fprintf(w, "hello, %s!\n", some_input)
}
[email protected]:~/localhost/api/src/generais$ go run main.go
# command-line-arguments
./main.go:13: cannot refer to unexported name kontroller.formEcho
./main.go:13: undefined: kontroller.formEcho
./main.go:14: cannot refer to unexported name kontroller.formPost
./main.go:14: undefined: kontroller.formPost
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question