L
L
ladozverxdd2017-09-01 22:49:20
go
ladozverxdd, 2017-09-01 22:49:20

Feature of HandleFunc in Go?

func index(w http.ResponseWriter, r *http.Request)  {
  fmt.Println("Index page")
}

Why is ResponseWriter passed simply and Request with a pointer?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
semt1, 2017-09-01
@semt1

Well, probably because ResponseWriter is an interface, that is, in fact, it is the pointer that is passed.
And Request is a structure.

A
Alexander Aksentiev, 2017-09-01
@Sanasol

piotrzurek.net/2013/09/20/pointers-in-go.html

Well, probably because ResponseWriter is an interface, that is, in fact, it is the pointer that is passed.
And Request is a structure.

something like that.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question