A TextMate bundle for the Go programming language.
Ruby Shell
#1 Compare This branch is 80 commits behind AlanQuatermain:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



(a TextMate language bundle) Version 1.2


Ensure you've got a recent copy of git installed, then copy this line to your Terminal application and run it:

> curl -L https://github.com/downloads/AlanQuatermain/go-tmbundle/install-go-tmbundle.sh | sh

This project has been modified a little since it was first published. The original repository (no longer updated) is available at github.com/AlanQuatermain/old-go-tmbundle


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.


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 return types. meth:: declares a function on a particular type, with additional tab stops for receiver name and type. 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. 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 range. go:: an immediate goroutine call (defines the function inline). de:: a deferred call (defines the function inline). main:: skeleton main() function. init:: skeleton init() function. +,+:: a pair ('first, second'). +<+:: send/receive through a channel. ret:: a return statement with optional return value.


Cmd-R:: Compile and run the current file. Cmd-B:: Build the current project using gomake. Cmd-Opt-B:: Build the current project as a package using gomake & gopack. Cmd-K:: Compile the current file. 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 be to lasersox and Infininight over at the #textmate room on IRC (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 :)