Sourcegraph provides intelligent searches of Go language code

Context-sensitive search engine for public and private source code repositories has a revamped, faster UI and is preparing to expand beyond Google's Go language

Code-search service Sourcegraph wants to distinguish itself as more than a glorified plaintext search of code in public and private GitHub repositories. The service applies the same kind of lexical analysis to code that an IDE does, so every function, package, and reference in a given library can be examined contextually.

Earlier this week, Sourcegraph unveiled a revamped front end for its service that the company claims is faster and easier to work with and is presented more like an IDE you might actually be working with on your own system.

Sourcegraph maintains an index of code in Google's Go language, harvested from GitHub repositories, that can be searched by simply typing the name of a repository, file, or object definition. When you bring up a given file, all the functions, variable definitions, and variable types in the file can be searched for intelligently.

The search isn't simply conducted in the current file or repository; it can also be performed across all files and repositories that Sourcegraph has indexed. Right-clicking on a function or object type returns a detailed description of that item, along with references to other places where it's used -- in the same manner as a desktop IDE.

clipboard02 InfoWorld

When browsing a Go source code repository with Sourcegraph, all references to a given function -- in this casen, NewRouter -- can be located throughout the repository. The search is done by intelligently analyzing the code, not simply by performing a full-text search.

The idea, Sourcegraph says, is to make "figuring out how to use libraries and understanding existing code a breeze," by allowing the developer to see, in context, how existing libraries are used and what other projects are employing them. 

Another touted selling point of Sourcegraph is the code browser itself, which was built with Microsoft's Monaco -- the same JavaScript-powered in-browser editor used to power Microsoft Visual Studio Code. Monaco handles large files well, and Sourcegraph makes use of its native features, like syntax highlighting.

The single biggest drawback to Sourcegraph -- one the company claims it's on the verge of changing -- is that it currently can index only code written in Go. The company's CEO hinted on Hacker News that support for other languages is in the works. Currently, if you open code from another language in Sourcegraph, such as Python, the code will feature the correct syntax highlighting, but Sourcegraph's specialized search functions won't work with it.

Like many offerings in this space, Sourcegraph has a free tier and an enterprise-centric for-pay tier. Users pay nothing for searches on public open source repositories and can search "single branch, latest commit" for private projects without paying either. The enterprise edition -- pricing is available only on request -- allows unlimited private branch/commit searches and has the option to run Sourcegraph "in your own network." This does not mean it's a self-hosted version of the product. The company has stated it will not have one "for the foreseeable future."

Copyright © 2016 IDG Communications, Inc.