View Default (OSX).sublime-keymap
1 2 3 4 5 6 7 8
[
// ... (existing content)
 
// Add folder that contains current file to sidebar.
{ "keys": ["f3"], "command": "add_to_project" },
 
// ...
]
View Default (OSX).sublime-keymap
1 2 3 4 5 6 7 8 9 10
[
// ... (existing content)
 
// Find selected text, even if it spans multiple lines (unlike "find_selected_text").
{ "keys": ["super+f"], "command": "run_multiple_commands", "args":
{ "commands":
[
// Only execute slurp if there's selected text.
{"command": "slurp_find_string", "context": "window", "condition": "selected_text"},
{"command": "show_panel", "args": {"panel": "find", "reverse": false}, "context": "window"}
View gist:6619001be6168d1abf66

go list tricks.

# Go package dependencies (all, recursive)
go list -f '{{join .Deps "\n"}}' ImportPath

# Go packages, command vs. library
go list -f '{{if eq .Name "main"}}/{{else}} {{end}} {{.ImportPath}}' all

# Find who imports "some/package" locally (including tests).
View gist:77cc54e53bbc0bf9a9a6

How I use GOPATH with multiple workspaces.

First off, I want to make it clear I have a fixed GOPATH that I do not change per project. The GOPATH env var is set inside my ~/.bash_profile file and doesn't change. Every Go package I have exists in no more than one place. I tend to have all my personal dependencies on latest version, simply because it's easier to have everything up to date than any alternative.

I do make use of the fact that the GOPATH environment variable is defined as a list of places rather than a single folder.

From http://golang.org/cmd/go/#hdr-GOPATH_environment_variable,

The GOPATH environment variable lists places to look for Go code. On Unix, the value is a colon-separated string. On Windows, the value is a semicolon-separated string. On Plan 9, the value is a list.

View gist:3f58c38dc262058c3e04

An example where var err error; something, err = foo() is nicer than something, err := foo().

This is a minority.

    fd := os.Stdout
    if *output != "" {
        var err error
        fd, err = os.Create(*output)
        if err != nil {
View main.go
1 2 3 4 5 6 7 8 9 10
package this_should_fail_to_compile_because_it_imports_nonexisting_package
 
import (
"fmt"
"net"
 
"github.com/samuel/go-zookeeper"
)
 
func main() {
View gist:5f9e93c38f6b75421060
1 2 3 4 5 6 7 8 9
<ul>
{{/* So simple... */}}
{{range .Cc.Commits}}<li>{{.Commit.Message}}</li>
{{end}}
 
{{/* Is this really the shortest/best way to to do reverse range? */}}
{{range $i, $v := .Cc.Commits}}<li>{{(index $.Cc.Commits (revIndex $i (len $.Cc.Commits))).Commit.Message}}</li>
{{end}}
</ul>
View gist:9f94bbd021b4693cf584

Code generated from protobufs:

public String getSomeId() {
    java.lang.Object ref = someId_;
    if (ref instanceof String) {
        return (String) ref;
    } else {
        com.google.protobuf.ByteString bs = 
            (com.google.protobuf.ByteString) ref;
View gist:81f1e59bb0db7febff94

go get

  • Benchmark three ways to get/update (from scratch) the same 17 Go packages contained in a single git repo.
go get -d -u github.com/shurcooL/go/cmd/gocd
go get -d -u github.com/shurcooL/go/cmd/table
go get -d -u github.com/shurcooL/go/exp/11
go get -d -u github.com/shurcooL/go/exp/12
Something went wrong with that request. Please try again.