You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To be clear are you suggesting there that "Run" should be highlighted in the second example?
What exactly is (c *exec.Cmd) syntactically here, the type of object the method applies to? Do the type defs always follow this exact pattern... could you provide some additional examples?
Although the Go documentation does not specifically mention its exact syntax, based on my personal experience, it can be defined in the above manner.
Generally speaking, we call a function that includes a Receiver part a Method, indicating that it can only be called as a "member function" of an instance of the type corresponding to the Receiver. Those without this part are ordinary Functions.
For Example:
funcExit(codeint) // simplestfuncSleep(d time.Duration) // a paramfuncSleep2(d, d2 time.Duration) // two params sharing the typefuncFormatInt(iint64, baseint) string// two params of different typesfuncFatal(v...interface{}) // the variadic paramfuncItoa(iint) string// with a return valuefuncAtoi(sstring) (int, error) // with two return value anonymousfunc (m*sync.Mutex) Lock() // with named receiverfunc (*sync.Mutex) Lock() // with anonymous receiver-----func (mtMyType) MyFunc(int, float32) (int, io.Reader, error) {
return0, nil, nil
}
Unfortunately, GitHub is also unable to handle the display of these syntax highlights effectively. Let's see how they are highlighted in VSCode:
Describe the issue
Just see the screenshot, methods of structs have different highlighting to simple functions.
Which language seems to have the issue?
Go
Are you using
highlight
orhighlightAuto
?hljs.highlightAll();
Sample Code to Reproduce
Expected behavior
Highlighting to method names just like function names.
Additional context
The text was updated successfully, but these errors were encountered: