← Back to context

Comment by shurcooL

11 years ago

This is neat; I want[1] something similar for Go types as well.

For example, say I'm looking at godoc for http://godoc.org/go/build#Package and I see all these descriptive comments for the fields:

    type Package struct {
        Dir         string   // directory containing package sources
        Name        string   // package name
        Doc         string   // documentation synopsis
        ImportPath  string   // import path of package ("" if unknown)
        Root        string   // root of Go tree where this package lives
        SrcRoot     string   // package source root directory ("" if unknown)
        PkgRoot     string   // package install root directory ("" if unknown)
        BinDir      string   // command install directory ("" if unknown)
        Goroot      bool     // package found in Go root
        PkgObj      string   // installed .a file
        AllTags     []string // tags that can influence file selection in this directory
        ConflictDir string   // this directory shadows Dir in $GOPATH
    
        // Source files
        GoFiles        []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)

I'd love to see a random sample data of that type, e.g.:

    (*build.Package)(&build.Package{
        Dir:         (string)("/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/shurcooL/go/vcs"),
        Name:        (string)("vcs"),
        Doc:         (string)("Package for getting status of a repo under vcs."),
        ImportPath:  (string)("github.com/shurcooL/go/vcs"),
        Root:        (string)("/Users/Dmitri/Dropbox/Work/2013/GoLand"),
        SrcRoot:     (string)("/Users/Dmitri/Dropbox/Work/2013/GoLand/src"),
        PkgRoot:     (string)("/Users/Dmitri/Dropbox/Work/2013/GoLand/pkg"),
        BinDir:      (string)("/Users/Dmitri/Dropbox/Work/2013/GoLand/bin"),
        Goroot:      (bool)(false),
        PkgObj:      (string)(""),
        AllTags:     ([]string)([]string{}),
        ConflictDir: (string)(""),
        GoFiles: ([]string)([]string{
            (string)("git.go"),
            (string)("hg.go"),
            (string)("vcs.go"),
        }),

(A couple of them, putting the most commonly occurring samples on top, etc.)

Perhaps Sourcegraph will offer something like this in the future.

[1] Well, I'm slowly working on achieving this myself in my spare time.