Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

add a few useful snippets #602

Merged
merged 2 commits into from
Nov 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion snippets/go.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,18 @@
"test function": {
"prefix": "tf",
"body": "func Test$1(t *testing.T) {\n\t$0\n}"
},
"init function": {
"prefix": "finit",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't init and main be better prefixes?

Copy link
Contributor Author

@marklap marklap Nov 4, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps. But I assumed folks would have the same trouble that #225 addresses particularly with the main function snippet. So, I used fmain and to be consistent, I used finit as well. I'm used to the #225 problem because SublimeText has it too and I've gotten used to escaping out of the autocomplete. So, if folks think main and init are better prefixes... that's fine with me.

Copy link
Contributor

@ramya-rao-a ramya-rao-a Nov 4, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue with main and #225 is valid. But does that apply to init as well?
My only concern was discoverability of these snippets.

(Randomly picking Go extension users who have recently logged issues :) + people from the #225 thread )
@zmb3 , @atombender, @bennyscetbun, @kulshekhar, @freeformz, @patbaker82, @lukehoban
Thoughts?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All things considered, fmain and init seem like the most apt options

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fmain and init work for me.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi my thought on this one.
I like consistency and many dev does too.
main/init should be good except that the #225 is a real pain when using it
So fmain/finit works fine for me :)
But please. No fmain/init or main/finit :)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @bennyscetbun.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistency does make sense and drive usability as well. Lets see if there is any other feedback over the weekend. I'll merge the PR (fmain and finit) on Monday if we don't hear anything more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that 'test function' uses tf and 'goroutine function' uses gf, maybe the main function can use mf while the 'init' function can use init (if might not be the best choice 🙂)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sigh.. This takes me back to a programmer's hardest task. http://imgur.com/y3dhJFQ : Naming things.

Going with fmain and finit

"body": "func init() {\n\t$1\n}"
},
"main function": {
"prefix": "fmain",
"body": "func main() {\n\t$1\n}"
},
"method declaration": {
"prefix": "meth",
"body": "func (${1:receiver} ${2:type}) ${3:method}($4) $5 {\n\t$0\n}"
}
}
}
}