R
R
Roman Rakzin2015-07-15 14:19:44
go
Roman Rakzin, 2015-07-15 14:19:44

Why is the function from the package not being called?

There is a main file
package main
import (
"net/http"
"./extensions"
)
func main() {
router := mux.NewRouter()
s := http.StripPrefix("/static/", http.FileServer(http. Dir("./files/")))
router.HandleFunc("/", handlers.Index)
router.PathPrefix("/static/").Handler(s)
http.Handle("/", router)
handlers. sayYess()
http.ListenAndServe(":5000", nil)
}
and file handlers.go
package handlers
import (
"log"
)
func sayYess() {
log.Println("yess")
}
func Index(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "hello")
}
sayYess() function not called Says
cannot refer to unexported name handlers.makeCache
and undefined: handlers.makeCache
Why others package functions work, but this one doesn't?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Rakzin, 2015-07-15
@TwoRS

Understood.
Oddly enough, the first letter must be
capitalized func SayYess() {
log.Println("yess")
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question