Skip to content
This repository
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 86 lines (69 sloc) 5.539 kb

Go

(a TextMate 2 language bundle) Version 2.0.1

Installation

The easiest way to install this bundle is to let TextMate 2 do the work for you: create a new .go file and open it in TextMate. The application will then suggest the Go language format and will download and install the bundle for you.

If you'd rather do things manually, or if you want to make changes to the repository, then in a Terminal window do:

mkdir ~/Library/Application\ Support/Avian/Bundles
cd ~/Library/Application\ Support/Avian/Bundles
git clone git://github.com/AlanQuatermain/go-tmbundle.git Go.tmbundle

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.

Support for Go 1.0 was provided by Jeremy Whitlock (github.com/whitlockjc) and Michael Sheets (github.com/infininight), with additional code and fixes from Sylvain Defresne (github.com/sdefresne), liuyork (github.com/liuyork), and Alexey Palazhchenko (github.com/AlekSi).

Snippets

Simple Statements

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.

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.

int

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

new

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.

Functions

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

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.

Commands

Cmd-K

Build the current package or executable.

Cmd-R

Compile and run the current file.

Cmd-Opt-T

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

Ctrl-Shift-H

Reformat the document according to the Go style guidelines.

Ctrl-H

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

<ESC>

Complete the symbol under the cursor.

Thanks

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

Contact Information

You can contact me through github, or you can ping me on Twitter or alpha.app.net as 'alanQuatermain'.

Happy coding :)

Something went wrong with that request. Please try again.