Star parameter - beginner

Hi everyone,
What is the star symbol (*) that appears before some func parameters? Ex.: request *http.Request

Kind regards

Savio

2 Likes

Hi,
I’m a beginner too. All that I know as of now is that it’s a pointer. So it accesses the value at the address (memory location) of the variable.

For example:
a := 10
b := &a
Then you can print the value of a by either saying
fmt.Printf("%v\n", a)
Or you can say
fmt.Printf("%v\n", *b)
But if you type
fmt.Printf("%v\n", b) (note the missing * before b)
You’ll get the memory address of variable a.
So in your case, I think the variable “request” is set to access the value pointed to by the http.Request.

3 Likes

Hi Pritesh,
Thanks for replying!
Regards

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.