func main(){
...
err := http.ListenAndServe(":9000", access_log(r))
if err != nil {
log.Fatal("HTTP server: ", err)
}
}
func access_log(r http.Handler) {
f, err := os.OpenFile("log/access.log", os.O_CREATE | os.O_WRONLY | os.O_APPEND, 0666)
if err != nil {
log.Panic("Access log: ", err)
}
return handlers.LoggingHandler(io.Writer(f), r)
}
# command-line-arguments
./main.go:71: access_log(r) used as value
./main.go:83: too many arguments to return
func access_log(r)
does not define the type for the parameter r.
Once you define it, the compilation should be able to proceed.
./main.go:83: too many arguments to return
The function as define as no return value, hence the error.
If you add the return type of handlers#LoggingHandler, that would be http.Handler
.
func access_log(r) http.Handler {
...
// Then you can return:
return handlers.LoggingHandler(io.Writer(f), r)
}