go-plus icon indicating copy to clipboard operation
go-plus copied to clipboard

Snippet for method generation

Open ghost opened this issue 10 years ago • 6 comments

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.

ghost avatar Jul 27 '15 09:07 ghost

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).

joefitzgerald avatar Jul 27 '15 17:07 joefitzgerald

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

joefitzgerald avatar Jul 27 '15 17:07 joefitzgerald

It's close, but not exactly what i had in mind. Thanks for your help though.

ghost avatar Jul 28 '15 12:07 ghost

Could you describe what exactly you had in mind in more detail?

joefitzgerald avatar Jul 28 '15 12:07 joefitzgerald

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.

ghost avatar Jul 28 '15 12:07 ghost

This is an interesting idea.

joefitzgerald avatar Aug 05 '15 15:08 joefitzgerald