gopaths

command module
v0.0.0-...-54b6b13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2014 License: MIT Imports: 12 Imported by: 0

README

gopaths GoDoc Build Status Build status

Go packages indexer. It searches for Go packages in GOROOT and GOPATH directories and then responds to shorter package paths with full paths. Useful together with 'cd' and 'godoc' commands.

Install

$ go get github.com/pietv/gopaths
$ go install github.com/pietv/gopaths

Usage

Service start:

$ gopaths -http=:6118 &

Search for a package:

$ curl :6118/imports/log
log
google.golang.org/appengine/internal/log
google.golang.org/appengine/log

Search for a directory containing the package:

$ curl :6118/dirs/rand
/Users/peter/go/src/crypto/rand
/Users/peter/go/src/math/rand

Update the index:

curl :6118/update

Documentation

Overview

The gopaths server responds to partial path requests with full package import or directory paths, depending on the request type.

Usage: gopaths [-http [HOST]:PORT] [-root DIRS] [-exclude FILE]

  -http=":6118"
	Listen on HOST on PORT.

  -root=""
     Directories to look for Go packages in, separated by ‘:’ in Unix
     and ‘;’ in Windows. By default, the packages are looked for
     in GOROOT and GOPATH.

  -exclude=""
     FILE containing a list of whitespace separated directory names
     in which gopaths won't be looking into when searching for packages.

Paths are matched against the base path (deepest sitting directory):

If there are many matches, all matches are returned; each on a separate line. If there are no package matches, paths leading to the base path are returned; again, if there are any.

For example, if the requested path is “io”, this path will be matched:

io

but these will be not:

bufio
testing/iotest
cmd/internal/rsc.io/x86/x86asm

On the other hand, if the requested path is “go.net”, and there are no indexed packages with “go.net” at the end, this path will be returned:

code.google.com/p/go.net

It's a parent path to many other packages.

The paths are queried using a Web browser, preferably a console one like curl(1) or wget(1), because gopaths is intended to be a CLI server.

There are three request types, specified by path prefixes:

GET /dirs/{PATH}
  Return directory paths matching PATH.

GET /imports/{PATH}
  Return import paths matching PATH.

GET /update
  Update the directory index. The directory index updates itself
  every 45 minutes. Occasionally, a faster update might be needed.

Examples:

$ curl :6118/imports/log
log
google.golang.org/appengine/internal/log
google.golang.org/appengine/log

$ curl :6118/dirs/rand
/Users/peter/go/src/crypto/rand
/Users/peter/go/src/math/rand

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL