Re: [go-nuts] Packages vs methods

2023-04-04 Thread 温博格
If one is using gopls for Go support for an IDE (like vscode), with semantic tokens enabled, the two cases are colored differently. It's incrementally cheap, as gopls already typechecks source. [to enable in vscode: in settings, in the gopls section, "ui.semanticTokens": true] I don't know that t

Re: [go-nuts] Packages vs methods

2023-04-04 Thread 'Axel Wagner' via golang-nuts
This ist actually a syntactical difference. Both are syntactically just selector expressions. So you'd need *semantic* highlighting, which not a lot of highlighters do. One reason is performance and another is that it means highlighting might fail for incorrectly typed (but syntactically valid) pr

Re: [go-nuts] Packages vs methods

2023-04-04 Thread Reto
On Mon, Apr 03, 2023 at 10:19:49PM -0700, joseph.p...@gmail.com wrote: > Is there an easy way to make > this determination? Sure, use syntax highlighting in your favor. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this gr

Re: [go-nuts] Packages vs methods

2023-04-03 Thread 'Axel Wagner' via golang-nuts
If you see `foo.bar()` it is definitely a method, as a package-scoped `bar` function would not be exported so it would not be visible in other packages. If, on the other hand, you see `foo.Bar()`, there is no easy way to tell. You have to know if `foo` is a variable or a package in the given scope.

[go-nuts] Packages vs methods

2023-04-03 Thread joseph.p...@gmail.com
When I’m reading go source and I see something like foo.bar(), my brain stutters for a second while I’m trying to determine if this is a reference to a package function or a receiver/method. Is there an easy way to make this determination? Thanks -- You received this message because you are s