A TextMate bundle for the Go programming language


(a TextMate 2 bundle for the go programming language)


  • Syntax highlighting
  • Run, build, test, and install packages
  • Code completion with gocode
  • View documentation with gogetdoc (Requires Go 1.6+)
  • Formatting with gofmt
  • Automatic imports with goimports
  • Linting with golint
  • Multiple linters supported with gometalinter
  • Find symbol information with godef
  • 45 snippets


TextMate should detect .go files and load this bundle automatically.

This bundle relies on amazing open source tooling for some functionality. These utilities can be installed with the following commands:

go get -u github.com/nsf/gocode					# completion
go get -u github.com/zmb3/gogetdoc				# documentation
go get -u golang.org/x/tools/cmd/goimports		# import resolution/rewriting
go get -u github.com/golang/lint/golint			# linting
go get -u github.com/rogpeppe/godef				# goto definition
go get -u github.com/alecthomas/gometalinter	# metalinting

You may override the following TextMate variables in the preferences (adjust paths to your own configuration). TextMate does not inherit the users environment unless it is launched from the command line. It may be necessary to set TM_GOPATH and GOROOT.

TM_GOFMT=/Users/myuser/bin/gofmt # or /Users/myuser/bin/goimports


Shortcut | Content ——- | ——- Cmd-R | Compile and run the current file. Cmd-Shift-R | Compile and test the current package. Cmd-B | Build the current package. Cmd-Shift-I | Install the current package. Cmd-Shift-D | Open either a package listed in imports or a user-supplied package. Ctrl-H | Show the Go HTML documentation for the currently-selected symbol. Cmd-D | Go to the original definition of the currently selected symbol. Ctrl-Shift-H | Reformat the document according to the Go style guidelines, automatically resolve imports. Ctrl-Shift-L | Run ‘go lint’ Ctrl-Shift-M | Run the default linters supplied by gometalinter Ctrl-Shift-V | Run ‘go vet’ Opt-ESC | Complete the symbol under the cursor.


Simple Statements

Snippet | Content ——- | ——- Cmd-i | ‘+iota+’ , | 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. def | A default clause within a switch. fmt | fmt.Println with tab stop for interface fmt. | fmt.Printf with tab stops for string and interface in | An empty interface type (i.e. matches anything). imp | An import statement with optional alternative name. imps | A multiple-import statement. pkg | A package declaration including an optional comment block for packages other than ‘main’. ret | A return statement with optional return value.

Initializers and Declarations

——- | ——-
| A short-form variable initializer (i.e. ‘name := value’). [] | A slice variable type; expands to ‘[]+type+’, so is usable inside other snippets. ch | A channel type. con | A single constant declaration. cons | A multiple constant declaration block. fun | A function type definition statement. inte | An interface definition with a single method. mk | A make statement (used for creating & initializing channels, maps, etc.). map | A map variable type; expands to ‘map[+keytype+]+valuetype+’. ew | A new statement (used to create & initialize structure types). st | A struct definition with a single member. type | A type declaration, with name and variable type as tab-stops. types | A block with multiple type declarations. 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.

ble declarations.


Snippet | Content ——- | ——- de | A deferred goroutine call (defines the function inline). 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. go | An immediate goroutine call (defines the function inline). init | A template for a module’s +init()+ function, with a tab stop at its body. main | A template for a +main()+ function with a tab stop at its body. meth | Declares a function on a particular type, with additional tab stops for receiver name and type and a single optional result. methv | Declares a function on a particular type, with additional tab stops for receiver name and type and multiple results.

Control Statements

Snippet | Content ——- | ——- case | A case clause, within a switch or select. 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. if | An if statement, properly formatted (Go requires the use of {} on ifs, unlike C; this throws me sometimes). sel | A select statement, for looping over channel conditions. sw | A switch statement with an optional expression.


This repository is a fork from Jim Dovey’s bundle with additional improvements merged from around the community. Changes from the original version (see git log for more details):

  • Substantially improved syntax highlighting (thanks nanoant)
  • Support for goimports and golint (thanks fmccann)
  • Support for godef (thanks taterbase)
  • Users can supply commands via ENV variables (TM_GO_DYNAMIC_GOPATH, TM_GO_DYNAMIC_PKG, TM_GO_DYNAMIC_PKG_PATH). The bundle will consult these commands if defined to dynamically change the gopath or package based on the current directory. (thanks fmccann)
  • all non-run go commands operate on the current directory instead of per file if the package is not defined dynamically. (thanks tg).
  • run and build work on unsaved files (thanks tg)
  • added print, println, printf, and fprintf snippets; improved struct snippet (thanks jish)
  • HiDPI completion icons (thanks nanoant)
  • Improved, expanded documentation coverage (thanks syscrusher)
  • Completion support for GOPATH and current package (thanks syscrusher)
  • bugfixes (thanks everyone!)

Jim Dovey deserves everyone’s gratitude for his hard work on this bundle. The following are his original attributions: >Much of the current infrastructure was created by Martin Kühl, who is a significantly more seasoned TextMate bundle developer than I, and to whom I am eternally grateful.

Support for Go 1.0 was provided by Jeremy Whitlock and Michael Sheets, with additional code and fixes from Sylvain Defresne, liuyork, and Alexey Palazhchenko.

Thanks be to lasersox and Infininight over at the #textmate room on IRC 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. Also Infininight’s work on updating the bundle to use the TextMate’s new Ruby interface and Jeremy & Sylvain’s work on supporting Go 1.0 has been invaluable. Their assistance and stewardship while I’ve been deep in the world of Objective-C is very much appreciated.

Happy coding :)

Related Repositories



A TextMate bundle for the Go programming language ...



A TextMate bundle for the Go programming language ...



A TextMate bundle for the Go programming language ...

Top Contributors

syscrusher mkhl AlanQuatermain sorbits nanoant dhowden jish infininight tg TassoLee guncha msoap taterbase AlekSi rdwampler sdefresne chrisseaton drnic fmccann whitlockjc schmurfy mkaz mkb218 KnightBaron rsesek robsonpeixoto tomaszj willfaught liuyork nicholasklick


-   v3.5.1 zip tar
-   v3.5.0 zip tar
-   v3.4.0 zip tar
-   v3.3.0 zip tar
-   v3.2.1 zip tar
-   v3.2.0 zip tar
-   v3.1.0 zip tar
-   v3.0.0 zip tar
-   v2.1.1 zip tar
-   RELEASE_1_3 zip tar
-   RELEASE_1_0_3 zip tar
-   RELEASE_1_0_2 zip tar
-   RELEASE_1_0_1 zip tar
-   RELEASE_1_0_0 zip tar