go-plus
go-plus copied to clipboard
Snippet for method generation
I've seen this feature in sublime's golang plugin and i was wondering if it's possible to create such a snippet. Say you have a struct foo, when you type it in an empty line the plugin suggests a method snippet -> func (f *foo)MyFunc(). Seeing as you already identify foo as a struct, im assuming this is somehow possible.
This sounds like a good snippet suggestion! Snippets should be added to language-go so that users of Atom benefit from them by default (even if they don't have go-plus installed).
Additionally, you might want to take a look at this snippet: https://github.com/atom/language-go/blob/564f13e36e0f03440ce2ed2715cf89fb564afc01/snippets/language-go.cson#L5-L7
It's close, but not exactly what i had in mind. Thanks for your help though.
Could you describe what exactly you had in mind in more detail?
lets say i have a type in my package:
type Foo int
I would like atom to create a snippet for a method. so say i type
Foo
atom will offer me to use a generateMethod snippet that will work for all types in the package
func (f *Foo)Method() {
The advantage of this snippet is that you don't need to specify the type's name, whereas in the snippet you presented you do.
This is an interesting idea.