# README
client-go

Babelfish Go client library provides functionality to both connect to the Babelfish server to parse code (obtaining an UAST as a result) and to analyse UASTs with the functionality provided by libuast.
Installation
The recommended way to install client-go is:
go get -u gopkg.in/bblfsh/client-go.v1/...
cd $GOPATH/src/gopkg.in/bblfsh/client-go.v1
make dependencies
Example
This small example illustrates how to retrieve the UAST from a small Python script.
If you don't have a bblfsh server running you can execute it using the following command:
docker run --privileged --rm -it -p 9432:9432 --name bblfsh bblfsh/server
Please read the getting started guide, to learn more about how to use and deploy a bblfsh server.
client, err := bblfsh.NewBblfshClient("0.0.0.0:9432")
if err != nil {
panic(err)
}
python := "import foo"
res, err := client.NewParseRequest().Language("python").Content(python).Do()
if err != nil {
panic(err)
}
fmt.Println(res.UAST)
Module {
. Roles: File
. Children: {
. . 0: Import {
. . . Roles: Statement,Declaration,Import
. . . StartPosition: {
. . . . Offset: 0
. . . . Line: 1
. . . . Col: 1
. . . }
. . . Properties: {
. . . . internalRole: body
. . . }
. . . Children: {
. . . . 0: alias {
. . . . . Roles: Import,Pathname,Identifier
. . . . . TOKEN "foo"
. . . . . Properties: {
. . . . . . asname: <nil>
. . . . . . internalRole: names
. . . . . }
. . . . }
. . . }
. . }
. }
}
License
Apache License 2.0, see LICENSE
# Functions
NewBblfshClient returns a new babelfish client given a server endpoint.
# Structs
BblfshClient holds the public client API to interact with the babelfish server.
ParseRequest is a placeholder for the parse requests performed by the library.