okcpt / Go.tmbundle

A TextMate bundle for the Go programming language.

Home Page:http://alanquatermain.net/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go

(a TextMate 2 language bundle) Version 1.3

Installation

Ensure you’ve got a recent copy of git installed, then in a Terminal window do:

mkdir "$HOME/Library/Application Supports/Avian/Bundles"
cd "$HOME/Library/Application Supports/Avian/Bundles"
git checkout git://github.com/sdefresne/Go.tmbundle.git

Features

The bundle here implements a language syntax, some snippets, and some compile/format/documentation commands for the Go language (golang.org/). Much of the current infrastructure was created by Martin Kühl (github.com/mkhl), who is a significantly more seasoned TextMate bundle developer than I, and to whom I am eternally grateful.

Snippets

pkg

A package declaration including an optional comment block for packages other than ‘main’.

imp

An import statement with optional alternative name.

imps

A multiple-import statement.

type

A type declaration, with name and variable type as tab-stops.

types

A block with multiple type declarations.

con

A single constant declaration.

cons

A multiple constant declaration block.

var

Declare a variable with an optional initial value (long form, i.e. ‘var x int = 10’).

vars

A block of long-form variable declarations.

func

A plain (global) function declaration, with tab stops for name, parameters, and a single optional result.

funcv

A plain (global) function declaration, with tab stops for name, parameters, and multiple results.

meth

Declares a function on a particular type, with additional tab stops for receiver name and type and a single optional result.

meth

Declares a function on a particular type, with additional tab stops for receiver name and type and multiple results.

in

An empty interface declaration (i.e. matches anything).

int

An interface definition with a single method.

st

A struct definition with a single member.

[]

A slice variable type; expands to ‘[]type’, so is usable inside other snippets.

map

A map variable type; works similar to the slice type above.

ch

A channel type.

fun

A function type definition statement.

:

A short-form variable initializer (i.e. ‘name := value’).

mk

A make statement (used for creating & initializing channels, maps, etc.).

new

A new statement (used to create & initialize structure types).

Cmd-i

iota

if

An if statement, properly formatted (Go requires the use of {} on ifs, unlike C; this throws me sometimes).

sw

A switch statement with an optional expression.

sel

A select statement, for looping over channel conditions.

case

A case clause, within a switch or select.

def

A default clause within a switch.

for

A for loop.

fori

A for loop with an index (similar to C for loops).

forr

A for loop iterating over a collection’s full range.

go

An immediate goroutine call (defines the function inline).

de

A deferred goroutine call (defines the function inline).

def

A simple deferred function call (by default supplies ‘+defer file.Close()+’).

main

A template for a +main()+ function with a tab stop at its body.

init

A template for a module’s +init()+ function, with a tab stop at its body.

,

A pair (‘first, second’), suitable for declaring result variables from a multi-return-value function or a map range loop.

<

Send/receive through a channel. Provides tab stops for the value and the channel name.

ret

A return statement with optional return value.

Commands

Cmd-K

Compile the current file.

Cmd-R

Compile and run the current file.

Cmd-B

Build the current package using “go install”.

Cmd-T

Launch the unittests for the current package using “go test”.

Ctrl-Shift-H

Reformat the document according to the Go style guidelines using gofmt.

Ctrl-H

Show the Go HTML documentation for the currently-selected symbol.

Thanks

Thanks be to lasersox and Infininight over at the #textmate room on IRC (irc.freenode.net/textmate) for all their help in cleaning up this here bundle, and for helping me to optimize my regex use in the language grammar. Thanks to Martin Kühl for his extensive additions to this project’s snippets and commands.

Contact Information

You can contact me through github, or you can ping me on Twitter as ‘alanQuatermain’.

Happy coding :)

About

A TextMate bundle for the Go programming language.

http://alanquatermain.net/

License:Other


Languages

Language:Ruby 100.0%