3 ms·
Why is it "q Query"?
by Noumenon72 8y ago
Why is it "q Query"?
- ovao 8y agoIn Go, the type follows the identifier. To use a single letter or short sequence of letters is idiomatic Go for short-lived identifiers or ‘quintessential’ identifiers.
- bbbobbb 8y agoThat the "receiver" identifier. You can think of it as "this" or "self" in other languages -> reference to the current "instance" within the method. https://gobyexample.com/methods https://gobyexample.com/methods
- dewey 8y agoq of type Query. So in the function you can access the fields on q (Where you call the function on) via q.FieldName. If you do it with a pointer receiver (q *Query) like explained here (https://tour.golang.org/methods/4 https://tour.golang.org/methods/4) you can directly manipulate the object, not the copy like in this example.