V
V
v- death2015-08-15 20:01:06
go
v- death, 2015-08-15 20:01:06

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))
}

Here is the controller code
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)
}

Compiling says not found
[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

Thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
index0h, 2015-08-15
@vGrabko99

Because you explicitly forbade it.
Available only as part of the package. If necessary, throughout the system - names with a capital letter

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question