Open
Description
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
or highlightAuto
?
hljs.highlightAll();
Sample Code to Reproduce
<pre><code>func deferFunc(err *error)</code></pre>
<br>
<pre><code>func (c *exec.Cmd) Run() error</code></pre>
Expected behavior
Highlighting to method names just like function names.
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
joshgoebel commentedon Jan 2, 2025
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?RickoNoNo3 commentedon Jan 3, 2025
Formally speaking, functions in Go can be defined using the following EBNF grammar language:
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:
Unfortunately, GitHub is also unable to handle the display of these syntax highlights effectively. Let's see how they are highlighted in VSCode: