GithubHelp home page GithubHelp logo

bblfsh / go-client Goto Github PK

View Code? Open in Web Editor NEW
37.0 7.0 20.0 493 KB

Babelfish Go client

Home Page: https://doc.bblf.sh/using-babelfish/clients.html

License: Apache License 2.0

Go 99.14% Makefile 0.86%
babelfish golang client

go-client's People

Contributors

abeaumont avatar bzz avatar campoy avatar carlosms avatar creachadair avatar dennwc avatar dpordomingo avatar eiso avatar juanjux avatar kuba-- avatar lwsanty avatar manucorporat avatar mcuadros avatar smacker avatar smola avatar vmarkovtsev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-client's Issues

Parsing of >4mb file fails

Right now if you try to running example from README to parse a single file of size >4mb - it will fail with:

panic: rpc error: code = ResourceExhausted desc = grpc: received message larger than max (6929586 vs. 4194304)

This is an umbrella issue for this problem that is not specific to client-go (all clients are affected), it was just found using go-client - all the fixes would belong to SDK/bblfshd/Drivers in separate PRs.

We already set max gRPC message size from bblfshd for gRPC server to 100Mb by default.
This issue is caused by the lack of same settings for the Driver gRPC server, as suggested by @dennwc offline and verifiled by @bzz with docker run --rm -p 9432:9432 bblfsh/go-driver.

Plan:

  • add same defaults to gRPC server in Drivers
  • make it configurable through CLI (same as other options are now set)
  • share this logic between bblfshd/drivers
  • release new version of SDK v2.8.0
  • release new version of all drivers (keeping bblfsh/sdk#326 in mind)
  • update bblfsh/documentation by make languages bblfsh/documentation#224
  • release new version of bblfshd v2.10.0 (after the drivers, so docker image \w all drivers v2.10.0-drivers go a new versions)

Transport closing when client is idle

Currently, the client opens a connection when the client is created and keeps it open even when idle. The connection can then be terminated if it's idle for too long.

However, there are cases when the gRPC library cannot determine connection state precisely and may fail the first request with transport closing after being idle for long enough.

The solution is to use a grpc.WithKeepaliveParams to keep the connection healthy while idle. We can either hard-code it or allow passing additional DialOptions when creating a client.

Nested XPath should not require *[1]

XPath over the results of another XPath does not work the way I expect it to work. It requires node dereferencing, though I don't understand why:

go run test.go

package main

import (
        "gopkg.in/bblfsh/client-go.v3"
	"gopkg.in/bblfsh/client-go.v3/tools"
	"gopkg.in/bblfsh/sdk.v2/uast/nodes"
	"gopkg.in/bblfsh/sdk.v2/uast/query"
)


func main() {
    client, err := bblfsh.NewClient("0.0.0.0:9432")
	if err != nil {
		panic(err)
	}
	request := client.NewParseRequest().
		Content(`// hello.java
import java.io.*;
import javax.servlet.*;

public class Hello extends GenericServlet {
    public void service(final ServletRequest request, final ServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html");
        final PrintWriter pw = response.getWriter();
        try {
            pw.println("Hello, world!");
        } finally {
            pw.close();
        }
    }
}
`).Filename("test.java").Mode(bblfsh.Annotated)
	root, _, err := request.UAST()
	if err != nil {
		panic(err)
	}
	it, err := tools.Filter(root, "//*[@role='Function' and @role='Declaration']")
	if err != nil {
		panic(err)
	}
	structs := query.AllNodes(it)
	for _, ext := range structs {
		node := ext.(nodes.Node)
		it, err := tools.Filter(node, "/name")
		if err != nil {
			panic(err)
		}
		println(query.Count(it))
	}
	println("===============")
	for _, ext := range structs {
		node := ext.(nodes.Node)
		it, err := tools.Filter(node, "/*[1]/name")
		if err != nil {
			panic(err)
		}
		println(query.Count(it))
	}
}

Output:

0
0
0
===============
1
1
1

As can be seen, accessing /name does not work but /[1]/name works.

`bblfsh-cli --help` gives help message two times

➜  ~ go get -u gopkg.in/bblfsh/client-go.v3/...
➜  ~ bblfsh-cli --help
Usage:
  bblfsh-cli [OPTIONS]

Application Options:
  -a, --host=     Babelfish endpoint address (default: localhost:9432)
  -l, --language= language to parse (default: auto)
  -q, --query=    XPath query applied to the resulting UAST
  -m, --mode=     UAST transformation mode: semantic, annotated, native
  -o, --out=      Output format: yaml, json, bin (default: yaml)

Help Options:
  -h, --help      Show this help message

couldn't parse flags: Usage:
  bblfsh-cli [OPTIONS]

Application Options:
  -a, --host=     Babelfish endpoint address (default: localhost:9432)
  -l, --language= language to parse (default: auto)
  -q, --query=    XPath query applied to the resulting UAST
  -m, --mode=     UAST transformation mode: semantic, annotated, native
  -o, --out=      Output format: yaml, json, bin (default: yaml)

Help Options:
  -h, --help      Show this help message

I expect to see

➜  ~ go get -u gopkg.in/bblfsh/client-go.v3/...
➜  ~ bblfsh-cli --help
Usage:
  bblfsh-cli [OPTIONS]

Application Options:
  -a, --host=     Babelfish endpoint address (default: localhost:9432)
  -l, --language= language to parse (default: auto)
  -q, --query=    XPath query applied to the resulting UAST
  -m, --mode=     UAST transformation mode: semantic, annotated, native
  -o, --out=      Output format: yaml, json, bin (default: yaml)

Help Options:
  -h, --help      Show this help message

Question: How do I read data from nodes?

The example in the docs provides a code snippet to extract the imports from the file. However marshalling nodes into JSON is not a good use case, and I am trying to find a way to get the name of the import without intermediate marhsaling.

	python := "import foo"
	res, _, err := client.NewParseRequest().Context(ctx).
		Language("python").Content(python).UAST()
	if err != nil {
		panic(err)
	}

	query := "//*[self::uast:Import or self::uast:RuntimeImport]"
	it, _ := tools.Filter(res, query)
	var nodeAr nodes.Array
	for it.Next() {
		fmt.Printf(it.Node().Name()) // <---- how do I do this?
	}

It is in the node under Path/Name, but how do I access it?

 { '@type': "uast:RuntimeImport",
      '@pos': { '@type': "uast:Positions",
         start: { '@type': "uast:Position",
            offset: 0,
            line: 1,
            col: 1,
         },
      },
      All: false,
      Names: ~,
      Path: { '@type': "uast:Identifier",
         '@pos': { '@type': "uast:Positions",
         },
         Name: "foo",
      },
      Target: ~,
   },
]

Also while testing it locally with a Go file the following was the output

      Path: { '@type': "uast:QualifiedIdentifier",
         '@pos': { '@type': "uast:Positions",
            start: { '@type': "uast:Position",
               offset: 171,
               line: 17,
               col: 2,
            },
            end: { '@type': "uast:Position",
               offset: 203,
               line: 17,
               col: 34,
            },
         },
         Names: [
            { '@type': "uast:Identifier",
               '@pos': { '@type': "uast:Positions",
                  start: { '@type': "uast:Position",
                     offset: 172,
                     line: 17,
                     col: 3,
                  },
                  end: { '@type': "uast:Position",
                     offset: 189,
                     line: 17,
                     col: 20,
                  },
               },
               Name: "google.golang.org",
            },
            { '@type': "uast:Identifier",
               '@pos': { '@type': "uast:Positions",
                  start: { '@type': "uast:Position",
                     offset: 190,
                     line: 17,
                     col: 21,
                  },
                  end: { '@type': "uast:Position",
                     offset: 193,
                     line: 17,
                     col: 24,
                  },
               },
               Name: "api",
            },
            { '@type': "uast:Identifier",
               '@pos': { '@type': "uast:Positions",
                  start: { '@type': "uast:Position",
                     offset: 194,
                     line: 17,
                     col: 25,
                  },
                  end: { '@type': "uast:Position",
                     offset: 202,
                     line: 17,
                     col: 33,
                  },
               },
               Name: "iterator",
            },
         ],
      },

Somehow Path/Name became Path/Names.

I can not find docs anywhere about how to read data from nodes.

Unsupported language using C# as driver

If you set C# as the language, bblfsh says "unsupported language", but if you use csharp it works. The thing is, C# is what enry returns, so it should work on bblfsh as well.

How to build nodes from scratch?

Before:

node := &uast.Node{}
node.InternalType = "whatever"
node.Token = "xxx"
node.Children = append(node.Children, &uast.Node{})

After?..

I need this for the tests.

Troubles to build the most recent version

sourced@sourced-MacBookPro:~/Projects$ git clone https://github.com/bblfsh/libuast
Cloning into 'libuast'...
remote: Counting objects: 564, done.
remote: Compressing objects: 100% (77/77), done.
remote: Total 564 (delta 66), reused 101 (delta 49), pack-reused 438
Receiving objects: 100% (564/564), 634.95 KiB | 318.00 KiB/s, done.
Resolving deltas: 100% (234/234), done.
Checking connectivity... done.
sourced@sourced-MacBookPro:~/Projects$ cd libuast/
sourced@sourced-MacBookPro:~/Projects/libuast$ cmake -DCMAKE_BUILD_TYPE=Release .
-- The C compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found CUnit: /usr/lib/x86_64-linux-gnu/libcunit.so (found version "2.1-3") 
-- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.9.3") 
-- The CXX compiler identification is GNU 5.4.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/sourced/Projects/libuast
sourced@sourced-MacBookPro:~/Projects/libuast$ make 
Scanning dependencies of target objlib
[  9%] Building C object CMakeFiles/objlib.dir/src/uast.c.o
[ 18%] Building C object CMakeFiles/objlib.dir/src/roles.c.o
[ 18%] Built target objlib
Scanning dependencies of target uast-static
[ 27%] Linking C static library lib/libuast.a
[ 27%] Built target uast-static
Scanning dependencies of target uast-shared
[ 36%] Linking C shared library lib/libuast.so
[ 36%] Built target uast-shared
Scanning dependencies of target example
[ 45%] Building CXX object examples/CMakeFiles/example.dir/example.cc.o
[ 54%] Linking CXX executable example
[ 54%] Built target example
Scanning dependencies of target testsuite
[ 63%] Building CXX object tests/CMakeFiles/testsuite.dir/main.cc.o
[ 72%] Building C object tests/CMakeFiles/testsuite.dir/__/src/testing_tools.c.o
[ 81%] Building C object tests/CMakeFiles/testsuite.dir/__/src/uast.c.o
[ 90%] Building C object tests/CMakeFiles/testsuite.dir/__/src/roles.c.o
[100%] Linking CXX executable testsuite
[100%] Built target testsuite
sourced@sourced-MacBookPro:~/Projects/libuast$ sudo make install
[sudo] password for sourced: 
[ 18%] Built target objlib
[ 27%] Built target uast-static
[ 36%] Built target uast-shared
[ 54%] Built target example
[100%] Built target testsuite
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/lib/libuast.a
-- Installing: /usr/local/include/libuast/uast.h
-- Installing: /usr/local/include/libuast/roles.h
-- Installing: /usr/local/include/libuast/node_iface.h
-- Installing: /usr/local/include/libuast/nodes.h
-- Installing: /usr/local/lib/libuast.so.0.0.0
-- Installing: /usr/local/lib/libuast.so.0
-- Installing: /usr/local/lib/libuast.so
-- Set runtime path of "/usr/local/lib/libuast.so.0.0.0" to ""
sourced@sourced-MacBookPro:~/Projects/libuast$ cd ../hercules/
sourced@sourced-MacBookPro:~/Projects/hercules$ go get gopkg.in/bblfsh/client-go.v0
# gopkg.in/bblfsh/client-go.v0
In file included from src/gopkg.in/bblfsh/client-go.v0/libuast.go:14:0:
./bindings.h:7:18: fatal error: uast.h: No such file or directory
compilation terminated.
sourced@sourced-MacBookPro:~/Projects/hercules$ CGO_CFLAGS="-I/usr/local/include/libuast" go get gopkg.in/bblfsh/client-go.v0
# gopkg.in/bblfsh/client-go.v0
/tmp/go-build738276561/gopkg.in/bblfsh/client-go.v0/_obj/_cgo_export.o: In function `CreateUast':
_cgo_export.c:(.text+0x123): undefined reference to `UastNew'
/tmp/go-build738276561/gopkg.in/bblfsh/client-go.v0/_obj/_cgo_export.o: In function `Filter':
_cgo_export.c:(.text+0x15b): undefined reference to `UastFilter'
/tmp/go-build738276561/gopkg.in/bblfsh/client-go.v0/_obj/_cgo_export.o: In function `Size':
_cgo_export.c:(.text+0x187): undefined reference to `NodesSize'
/tmp/go-build738276561/gopkg.in/bblfsh/client-go.v0/_obj/_cgo_export.o: In function `At':
_cgo_export.c:(.text+0x1a8): undefined reference to `NodeAt'
/tmp/go-build738276561/gopkg.in/bblfsh/client-go.v0/_obj/libuast.cgo2.o: In function `CreateUast':
libuast.cgo2.c:(.text+0x123): undefined reference to `UastNew'
/tmp/go-build738276561/gopkg.in/bblfsh/client-go.v0/_obj/libuast.cgo2.o: In function `Filter':
libuast.cgo2.c:(.text+0x15b): undefined reference to `UastFilter'
/tmp/go-build738276561/gopkg.in/bblfsh/client-go.v0/_obj/libuast.cgo2.o: In function `Size':
libuast.cgo2.c:(.text+0x187): undefined reference to `NodesSize'
/tmp/go-build738276561/gopkg.in/bblfsh/client-go.v0/_obj/libuast.cgo2.o: In function `At':
libuast.cgo2.c:(.text+0x1a8): undefined reference to `NodeAt'
collect2: error: ld returned 1 exit status
sourced@sourced-MacBookPro:~/Projects/hercules$ CGO_CFLAGS="-I/usr/local/include/libuast" CGO_LDFLAGS="-luast" go get gopkg.in/bblfsh/client-go.v0
sourced@sourced-MacBookPro:~/Projects/hercules$ (success)

I propose to add the most common include paths and -luast to CGO definitions in Go code.

How to mutate nodes?

My next question is: OK, I know how to retrieve attribute values using uast.TokenOf, uast.PositionsOf, etc., but how can I change those values in some nodes? There are no uast.Set* counterparts...

Differentiate `Invalid expression` error and others on tools.Filter

Currently, any error happened in tools.Filter returns FatalError.
Though Invalid expression means the input is wrong and a user is able to fix it.
Other errors are "internal" errors. But there is no way to differentiate them (besides comparing text of error which is super wrong).

It's needed especially for web services which uses client-go.

Installation instructions in the readme

I followed the installation instructions listed in the README and they worked. However, the first command fails with

# gopkg.in/bblfsh/client-go.v2/tools
In file included from ../../bblfsh/client-go.v2/tools/filter.go:14:0:
./bindings.h:8:18: fatal error: uast.h: No such file or directory
compilation terminated.

I understand that this is intended because make deps fixes it. Should we put a notice there in the README that the first command will fail and it is normal?

Language name does not match Enry's

Right now, if you set Python as language, it fails because driver is missing, but python works. That prevents piping enry results to bblfsh.

Is this expected to accept enry outputs as inputs or this should be handled by the specific application?
Right now we're just lowercasing, but that it's not correct for all languages (although it is for the ones we have right now).

package name doesn't match import path

It's non idiomatic to define a package with a name differing the last component of its import path.

When importing "gopkg.in/bblfsh/client-go.v2" the identifier added to the namespace of the program is unexpectedly bblfsh.

Is there any good reason for this that I'm missing out?

Fix an example

The example:

client, err := bblfsh.NewClient("0.0.0.0:9432")
if err != nil {
    panic(err)
}

python := "import foo"

res, _, err := client.NewParseRequest().Language("python").Content(python).UAST()
if err != nil {
    panic(err)
}

query := "//*[@role='Import']"
nodes, _ := tools.Filter(res.UAST, query) // res is an interface, no .UAST
for _, n := range nodes {
    fmt.Println(n)
}

does not compile with client-go.v3
Function: func (r *ParseRequest) UAST() (Node, string, error) returns a Node which is an alias:

// Node is a generic UAST node.
type Node = nodes.Node

And Node from "gopkg.in/bblfsh/sdk.v2/uast/nodes" is an interface, so doesn't have a member UAST.

Panic: makeslice: cap out of range

Sometimes, client-go panics with the following error:

runtime error: makeslice: cap out of range
/usr/local/Cellar/go/1.10.1/libexec/src/runtime/panic.go:502 (0x402be48)
	gopanic: reflectcall(nil, unsafe.Pointer(d.fn), deferArgs(d), uint32(d.siz), uint32(d.siz))
/usr/local/Cellar/go/1.10.1/libexec/src/runtime/slice.go:58 (0x4041d31)
	makeslice: panic(errorString("makeslice: cap out of range"))
/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools/bindings.go:245 (0x47c53d7)
	com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools.getPropertyKeys: keys := make([]string, 0, len(p))
/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools/bindings.go:256 (0x47c563a)
	com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools.goGetPropertyKey: keys := getPropertyKeys(ptr)
_cgo_gotypes.go:340 (0x47c4601)
/usr/local/Cellar/go/1.10.1/libexec/src/runtime/asm_amd64.s:573 (0x4054f9a)
	call32: CALLFN(·call32, 32)
/usr/local/Cellar/go/1.10.1/libexec/src/runtime/cgocall.go:316 (0x40042fb)
	cgocallbackg1: reflectcall(nil, unsafe.Pointer(cb.fn), cb.arg, uint32(cb.argsize), 0)
/usr/local/Cellar/go/1.10.1/libexec/src/runtime/cgocall.go:194 (0x40040c9)
	cgocallbackg: cgocallbackg1(ctxt)
/usr/local/Cellar/go/1.10.1/libexec/src/runtime/asm_amd64.s:826 (0x405656a)
	cgocallback_gofunc: CALL	runtime·cgocallbackg(SB)
/usr/local/Cellar/go/1.10.1/libexec/src/runtime/asm_amd64.s:673 (0x4056401)
	asmcgocall: CALL	gosave<>(SB)
/usr/local/Cellar/go/1.10.1/libexec/src/runtime/cgocall.go:131 (0x4003f77)
	cgocall: errno := asmcgocall(fn, arg)
_cgo_gotypes.go:107 (0x47c3f09)
/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools/bindings.go:122 (0x47c50c3)
	com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools.Filter: if !C.Filter(ptr, cquery) {

We're checking the errors and the response status is Ok.

If it's of any help, the XPath for the filter was //FunctionGroup.

Fix tests

Two tests are currently failing in Travis:

--- FAIL: TestClient_NewParseRequest (0.00s)
	Error Trace:	client_test.go:20
	Error:      	Not equal: 
	            	expected: 1
	            	actual  : 0
	Test:       	TestClient_NewParseRequest
=== RUN   TestClient_NewNativeParseRequest
--- FAIL: TestClient_NewNativeParseRequest (0.00s)
	Error Trace:	client_test.go:35
	Error:      	Not equal: 
	            	expected: 1
	            	actual  : 0
	Test:       	TestClient_NewNativeParseRequest

The build still succeeds. Would be great to fix the tests and also fail the build if tests fail.

Installation fails to compile libuast due network failure

go-client user's CI fails on libuast building step i.e in https://travis-ci.org/bblfsh/dashboard/builds/361636871 with

./bindings.h:13:26: fatal error: libuast/uast.h: No such file or directory
 #include "libuast/uast.h"
                          ^
compilation terminated.

on what actually looks like a networking failure on fetching libuast. Full build log here.

It would be nice to be more explicit and check if download fails, and then retry i.e something like this helper in Gemini.

AFAIK in curl, something like

curl --connect-timeout 5 \
     --max-time 10 \
     --retry 5 \
     --retry-delay 0 \
     --retry-max-time 60

plus checking the exit code before piping it to tar (or with PIPESTATUS ) would do the trick.

Windows build warnings

This is to keep track of the issues I had with building client-go on Windows.

$ go get -v gopkg.in/bblfsh/client-go.v2/...
gopkg.in/bblfsh/client-go.v2/tools
# gopkg.in/bblfsh/client-go.v2/tools
In file included from Users\User\go\src\gopkg.in\bblfsh\client-go.v2\tools\filter.go:14:0,
                 from _cgo_export.c:3:
Users\User\go\src\gopkg.in\bblfsh\client-go.v2\tools/bindings.h: In function 'CreateUast':
Users\User\go\src\gopkg.in\bblfsh\client-go.v2\tools/bindings.h:49:23: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
       .ChildrenSize = ChildrenSize,
                       ^
Users\User\go\src\gopkg.in\bblfsh\client-go.v2\tools/bindings.h:49:23: note: (near initialization for '(anonymous).ChildrenSize')
Users\User\go\src\gopkg.in\bblfsh\client-go.v2\tools/bindings.h:51:20: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
       .RolesSize = RolesSize,
                    ^
Users\User\go\src\gopkg.in\bblfsh\client-go.v2\tools/bindings.h:51:20: note: (near initialization for '(anonymous).RolesSize')
# gopkg.in/bblfsh/client-go.v2/tools
In file included from Users\User\go\src\gopkg.in\bblfsh\client-go.v2\tools\filter.go:14:0:
Users\User\go\src\gopkg.in\bblfsh\client-go.v2\tools/bindings.h: In function 'CreateUast':
Users\User\go\src\gopkg.in\bblfsh\client-go.v2\tools/bindings.h:49:23: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
       .ChildrenSize = ChildrenSize,
                       ^
Users\User\go\src\gopkg.in\bblfsh\client-go.v2\tools/bindings.h:49:23: note: (near initialization for '(anonymous).ChildrenSize')
Users\User\go\src\gopkg.in\bblfsh\client-go.v2\tools/bindings.h:51:20: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
       .RolesSize = RolesSize,
                    ^

Is v2.2 broken on MacOs?

smacker at Maxims-MacBook-Pro in ~/go/src/gopkg.in/bblfsh
$ rm -rf client-go.v2/
smacker at Maxims-MacBook-Pro in ~/go/src/gopkg.in/bblfsh
$ go get -d -u gopkg.in/bblfsh/client-go.v2/...
smacker at Maxims-MacBook-Pro in ~/go/src/gopkg.in/bblfsh
$ cd $GOPATH/src/gopkg.in/bblfsh/client-go.v2
smacker at Maxims-MacBook-Pro in ~/go/src/gopkg.in/bblfsh/client-go.v2 on master*
$ make dependencies
go get -v -t gopkg.in/bblfsh/client-go.v2
gopkg.in/bblfsh/client-go.v2
go get -v -t gopkg.in/bblfsh/client-go.v2/tools
gopkg.in/bblfsh/client-go.v2/tools
# gopkg.in/bblfsh/client-go.v2/tools
In file included from tools/bindings.go:15:
./bindings.h:8:10: fatal error: 'uast.h' file not found
#include "uast.h"
         ^~~~~~~~
1 error generated.
make: [gopkg.in/bblfsh/client-go.v2/tools] Error 2 (ignored)
curl -SL https://github.com/bblfsh/libuast/releases/download/v1.6.1/libuast-v1.6.1.tar.gz | tar xz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   611    0   611    0     0    611      0 --:--:-- --:--:-- --:--:--  1168
100 21516  100 21516    0     0  21516      0  0:00:01  0:00:01 --:--:-- 21516
mv libuast-v1.6.1/src/* tools/.
rm -rf libuast-v1.6.1
go get -v -t .
smacker at Maxims-MacBook-Pro in ~/go/src/gopkg.in/bblfsh/client-go.v2 on master*
$ make dependencies
go get -v -t gopkg.in/bblfsh/client-go.v2
go get -v -t gopkg.in/bblfsh/client-go.v2/tools
gopkg.in/bblfsh/client-go.v2/tools
# gopkg.in/bblfsh/client-go.v2/tools
In file included from _cgo_export.c:3:
In file included from tools/bindings.go:15:
tools/bindings.h:160:1: warning: control reaches end of non-void function [-Wreturn-type]
# gopkg.in/bblfsh/client-go.v2/tools
In file included from tools/bindings.go:15:
tools/bindings.h:160:1: warning: control reaches end of non-void function [-Wreturn-type]
# gopkg.in/bblfsh/client-go.v2/tools
uast.cc:44:33: error: non-aggregate type 'const std::vector<const char *>' cannot be initialized with an initializer list
uast.cc:82:5: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
uast.cc:234:5: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
uast.cc:247:5: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
uast.cc:248:5: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
uast.cc:462:3: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
make: [gopkg.in/bblfsh/client-go.v2/tools] Error 2 (ignored)
curl -SL https://github.com/bblfsh/libuast/releases/download/v1.6.1/libuast-v1.6.1.tar.gz | tar xz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   611    0   611    0     0    611      0 --:--:-- --:--:-- --:--:--   901
100 21516  100 21516    0     0  21516      0  0:00:01  0:00:01 --:--:-- 21516
mv libuast-v1.6.1/src/* tools/.
rm -rf libuast-v1.6.1
go get -v -t .

Then when I run anything that uses client-go I have:

$ go run main.go
# gopkg.in/bblfsh/client-go.v2/tools
In file included from _cgo_export.c:3:
In file included from ../../go/src/gopkg.in/bblfsh/client-go.v2/tools/bindings.go:15:
../../go/src/gopkg.in/bblfsh/client-go.v2/tools/bindings.h:160:1: warning: control reaches end of non-void function [-Wreturn-type]
# gopkg.in/bblfsh/client-go.v2/tools
In file included from ../../go/src/gopkg.in/bblfsh/client-go.v2/tools/bindings.go:15:
../../go/src/gopkg.in/bblfsh/client-go.v2/tools/bindings.h:160:1: warning: control reaches end of non-void function [-Wreturn-type]
# gopkg.in/bblfsh/client-go.v2/tools
uast.cc:44:33: error: non-aggregate type 'const std::vector<const char *>' cannot be initialized with an initializer list
uast.cc:82:5: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
uast.cc:234:5: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
uast.cc:247:5: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
uast.cc:248:5: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
uast.cc:462:3: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
smacker at Maxims-MacBook-Pro in ~/Dev/hercules-web on master*
$ echo $?
2

Question: provide underlying service client?

We need to call bblfsh server to get list of drivers in dashboard: bblfsh/web#89

Currently we open connection with client-go.Client to do all requests to the server using it and keep it open.
It sounds a little bit weird to create one more protocol.ProtocolServiceClient when we have one already inside client-go.Client.
Do you think it makes sense to add a method like

func(c *Client) ProtocolService() protocol.ProtocolServiceClient {}

?

Please share your opinion!

@abeaumont

panic: unexpected fault address

After the fix in 2.8.0 for #69 this new panic appears:

unexpected fault address 0xb01dfacedebac1e
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb01dfacedebac1e pc=0x4057fe5]

goroutine 50 [running, locked to thread]:
runtime.throw(0x4b1f0bb, 0x5)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/panic.go:616 +0x81 fp=0xc42127d398 sp=0xc42127d378 pc=0x402c011
runtime.sigpanic()
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/signal_unix.go:395 +0x211 fp=0xc42127d3e8 sp=0xc42127d398 pc=0x4040b81
runtime.memmove(0x122df000, 0x6c616e7265746e69, 0x40000000)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/memmove_amd64.s:389 +0x485 fp=0xc42127d3f0 sp=0xc42127d3e8 pc=0x4057fe5
github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools._Cfunc_CString(0x6c616e7265746e69, 0x656c6f52, 0x0)
	_cgo_gotypes.go:72 +0x65 fp=0xc42127d420 sp=0xc42127d3f0 pc=0x47c5e05
github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools.(*cstringPool).getCstring(0x567de60, 0x6c616e7265746e69, 0x656c6f52, 0xc42127d4b0)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools/cstring_pool.go:12 +0x39 fp=0xc42127d478 sp=0xc42127d420 pc=0x47c77f9
github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools.goGetInternalType(0xc420b9c9e0, 0x4c3dfa8)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools/bindings.go:204 +0x43 fp=0xc42127d4a8 sp=0xc42127d478 pc=0x47c72f3
github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools._cgoexpwrap_41f7380b1fa0_goGetInternalType(0xc420b9c9e0, 0x0)
	_cgo_gotypes.go:243 +0x5a fp=0xc42127d4d0 sp=0xc42127d4a8 pc=0x47c61ca
runtime.call32(0x0, 0x7000014f87b0, 0x7000014f8840, 0x10)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/asm_amd64.s:573 +0x3b fp=0xc42127d500 sp=0xc42127d4d0 pc=0x4054b2b
runtime.cgocallbackg1(0x0)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/cgocall.go:316 +0x19c fp=0xc42127d580 sp=0xc42127d500 pc=0x4003e8c
runtime.cgocallbackg(0x0)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/cgocall.go:194 +0xda fp=0xc42127d5e8 sp=0xc42127d580 pc=0x4003c5a
runtime.cgocallback_gofunc(0x4003b08, 0x48bcdc0, 0xc42127d688, 0xc42118b6a0)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/asm_amd64.s:826 +0x9b fp=0xc42127d608 sp=0xc42127d5e8 pc=0x40560fb
runtime.asmcgocall(0x48bcdc0, 0xc42127d688)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/asm_amd64.s:673 +0x42 fp=0xc42127d610 sp=0xc42127d608 pc=0x4055f92
runtime.cgocall(0x48bcdc0, 0xc42127d688, 0x0)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/cgocall.go:131 +0x88 fp=0xc42127d648 sp=0xc42127d610 pc=0x4003b08
github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools._Cfunc_Filter(0xc4211fb110, 0x83001d0, 0x0)
	_cgo_gotypes.go:107 +0x4a fp=0xc42127d688 sp=0xc42127d648 pc=0x47c5f5a
github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools.Filter(0xc4211fb110, 0xc420228200, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools/bindings.go:122 +0xc4 fp=0xc42127d700 sp=0xc42127d688 pc=0x47c7114

Previously we used to recover in the UAST function of gitbase just to not make the server crash after a bblfsh panic. This one was not caught by the recover.

errors returned are gRPC errors

Errors returned by the client are all gRPC errors, so you can't distinguish for example if that error is an driver.ErrPartialParse error.

How to map nodes?

I need to maintain a mapping from nodes.Node to values, however, it is an interface type and hence cannot be hashed. When I used to work with *uast.Node, I did not have this problem because I worked with pointers. What is the recommended way to map nodes in v2?

Installation process should not require make dependencies

Go libraries are expected to be perfectly buildable after doing go get, which is not the case for this library, since it cannot be used before making make dependencies. This makes transitively all projects using it require a step to make the dependencies of this library, which is a pain.

Isn't there a way to avoid this step either by including whatever it's downloading in a bindata or something?

UAST filtering/marshalling randomly panics

Some files panic randomly while using tools.Filter or node.Marshal

Reproduction case:

func TestBblfshFailing(t *testing.T) {
	xpath := `//*[@roleFunction and @roleDeclaration]`
	code := `package hdfs

import (
        "bytes"
        "encoding/hex"
        "hash/crc32"
        "io"
        "io/ioutil"
        "math/rand"
        "os"
        "testing"
        "time"

        "github.com/stretchr/testify/assert"
        "github.com/stretchr/testify/require"
)

const (
        // many grep -b died to bring us this information...
        testStr    = "Abominable are the tumblers into which he pours his poison."
        testStrOff = 48847

        testStr2            = "http://www.gutenberg.org"
        testStr2Off         = 1256988
        testStr2NegativeOff = -288

        testChecksum = "27c076e4987344253650d3335a5d08ce"
)

func TestFileRead(t *testing.T) {
        client := getClient(t)

        file, err := client.Open("/_test/foo.txt")
        require.NoError(t, err)

        bytes, err := ioutil.ReadAll(file)
        assert.NoError(t, err)
        assert.EqualValues(t, "bar\n", string(bytes))

        info := file.Stat()
        assert.False(t, info.IsDir())
        assert.EqualValues(t, 4, info.Size())
        assert.EqualValues(t, time.Now().Year(), info.ModTime().Year())
        assert.EqualValues(t, time.Now().Month(), info.ModTime().Month())
}

func TestReadEmptyFile(t *testing.T) {
        client := getClient(t)

        touch(t, "/_test/emptyfile")

        file, err := client.Open("/_test/emptyfile")
        require.NoError(t, err)

        bytes, err := ioutil.ReadAll(file)
        assert.NoError(t, err)
        assert.EqualValues(t, "", string(bytes))
}

func TestFileBigRead(t *testing.T) {
        client := getClient(t)

        file, err := client.Open("/_test/mobydick.txt")
        require.NoError(t, err)

        hash := crc32.NewIEEE()
        n, err := io.Copy(hash, file)
        assert.NoError(t, err)
        assert.EqualValues(t, n, 1257276)
        assert.EqualValues(t, 0x199d1ae6, hash.Sum32())
}

func TestFileBigReadWeirdSizes(t *testing.T) {
        client := getClient(t)

        file, err := client.Open("/_test/mobydick.txt")
        require.NoError(t, err)

        hash := crc32.NewIEEE()
        copied := 0
        var n int64
        for err == nil {
                n, err = io.CopyN(hash, file, int64(rand.Intn(1000)))
                copied += int(n)
        }

        assert.EqualValues(t, io.EOF, err)
        assert.EqualValues(t, 0x199d1ae6, hash.Sum32())
        assert.EqualValues(t, copied, 1257276)
}

func TestFileBigReadN(t *testing.T) {
        client := getClient(t)

        file, err := client.Open("/_test/mobydick.txt")
        require.NoError(t, err)

        n, err := io.CopyN(ioutil.Discard, file, 1000000)
        assert.NoError(t, err)
        assert.EqualValues(t, n, 1000000)
}

func TestFileReadAt(t *testing.T) {
        client := getClient(t)

        file, err := client.Open("/_test/mobydick.txt")
        require.NoError(t, err)

        buf := make([]byte, len(testStr))
        off := 0
        for off < len(buf) {
                n, err := file.ReadAt(buf[off:], int64(testStrOff+off))
                assert.NoError(t, err)
                assert.True(t, n > 0)
                off += n
        }

        assert.EqualValues(t, string(buf), testStr)

        buf = make([]byte, len(testStr2))
        off = 0
        for off < len(buf) {
                n, err := file.ReadAt(buf[off:], int64(testStr2Off+off))
                assert.NoError(t, err)
                assert.True(t, n > 0)
                off += n
        }

        assert.EqualValues(t, testStr2, string(buf))
}

func TestFileSeek(t *testing.T) {
        client := getClient(t)

        file, err := client.Open("/_test/mobydick.txt")
        require.NoError(t, err)

        buf := new(bytes.Buffer)

        off, err := file.Seek(testStrOff, 0)
        assert.NoError(t, err)
        assert.EqualValues(t, testStrOff, off)

        n, err := io.CopyN(buf, file, int64(len(testStr)))
        assert.NoError(t, err)
        assert.EqualValues(t, len(testStr), n)
        assert.EqualValues(t, testStr, string(buf.Bytes()))

        // seek backwards and read it again
        off, err = file.Seek(-1*int64(len(testStr)), 1)
        assert.NoError(t, err)
        assert.EqualValues(t, testStrOff, off)

        buf.Reset()
        n, err = io.CopyN(buf, file, int64(len(testStr)))
        assert.NoError(t, err)
        assert.EqualValues(t, len(testStr), n)
        assert.EqualValues(t, testStr, string(buf.Bytes()))

        // now seek forward to another block and read a string
        off, err = file.Seek(testStr2NegativeOff, 2)
        assert.NoError(t, err)
        assert.EqualValues(t, testStr2Off, off)

        buf.Reset()
        n, err = io.CopyN(buf, file, int64(len(testStr2)))
        assert.NoError(t, err)
        assert.EqualValues(t, len(testStr2), n)
        assert.EqualValues(t, testStr2, string(buf.Bytes()))
}

func TestFileReadDir(t *testing.T) {
        client := getClient(t)

        mkdirp(t, "/_test/fulldir3")
        mkdirp(t, "/_test/fulldir3/dir")
        touch(t, "/_test/fulldir3/1")
        touch(t, "/_test/fulldir3/2")
        touch(t, "/_test/fulldir3/3")

        file, err := client.Open("/_test/fulldir3")
        require.NoError(t, err)

        res, err := file.Readdir(2)
        require.Equal(t, 2, len(res))
        assert.EqualValues(t, "1", res[0].Name())
        assert.EqualValues(t, "2", res[1].Name())

        res, err = file.Readdir(5)
        require.Equal(t, 2, len(res))
        assert.EqualValues(t, "3", res[0].Name())
        assert.EqualValues(t, "dir", res[1].Name())

        res, err = file.Readdir(0)
        require.Equal(t, 4, len(res))
        assert.EqualValues(t, "1", res[0].Name())
        assert.EqualValues(t, "2", res[1].Name())
        assert.EqualValues(t, "3", res[2].Name())
        assert.EqualValues(t, "dir", res[3].Name())
}

func TestFileReadDirnames(t *testing.T) {
        client := getClient(t)

        mkdirp(t, "/_test/fulldir4")
        mkdirp(t, "/_test/fulldir4/dir")
        touch(t, "/_test/fulldir4/1")
        touch(t, "/_test/fulldir4/2")
        touch(t, "/_test/fulldir4/3")

        file, err := client.Open("/_test/fulldir4")
        require.NoError(t, err)

        res, err := file.Readdirnames(0)
        require.Equal(t, 4, len(res))
        assert.EqualValues(t, []string{"1", "2", "3", "dir"}, res)
}

func TestOpenFileWithoutPermission(t *testing.T) {
        otherClient := getClientForUser(t, "other")

        mkdirp(t, "/_test/accessdenied")
        touch(t, "/_test/accessdenied/foo")

        file, err := otherClient.Open("/_test/accessdenied/foo")
        assert.Nil(t, file)
        assertPathError(t, err, "open", "/_test/accessdenied/foo", os.ErrPermission)
}

func TestFileChecksum(t *testing.T) {
        client := getClient(t)

        file, err := client.Open("/_test/foo.txt")
        require.NoError(t, err)

        checksum, err := file.Checksum()
        require.NoError(t, err)

        assert.EqualValues(t, testChecksum, hex.EncodeToString(checksum))
}`
	client, err := bblfsh.NewClient("127.0.0.1:9432")
	require.NoError(t, err)
	resp, err := client.NewParseRequest().
		Content(code).
		Language("Go").
		Do()
	require.NoError(t, err)

	_, err = tools.Filter(resp.UAST, xpath)
	require.NoError(t, err)
}

Example error (though it fails some times with other errors):

Assertion failed: (node), function UastFilter, file uast.cc, line 268.
SIGABRT: abort
PC=0x7fff7b632e3e m=8 sigcode=0

goroutine 0 [idle]:
runtime: unknown pc 0x7fff7b632e3e
stack: frame={sp:0x700001f14d08, fp:0x0} stack=[0x700001e95290,0x700001f14e90)
0000700001f14c08:  0000000000000000  00007fff7b5b8e05 
0000700001f14c18:  00000000056e2000  0000000000000000 
0000700001f14c28:  00007fff7b5b8e64  0000700001f14c90 
0000700001f14c38:  00007fff7b7650d0  0000000000000000 
0000700001f14c48:  0000000000000000  00007fff7b5b8e05 
0000700001f14c58:  0000700001f14ca0  0000000000000002 
0000700001f14c68:  0000000005384fe6  0000000005384f95 
0000700001f14c78:  00000000056e2000  000000000000010c 
0000700001f14c88:  0000000005384f56  0000700001f14d70 
0000700001f14c98:  00007fff7b76507d  0000003000000030 
0000700001f14ca8:  0000700001f14d80  0000700001f14cc0 
0000700001f14cb8:  000000000000010c  0000000000000000 
0000700001f14cc8:  0000000005648a00  0000000005384f95 
0000700001f14cd8:  0000000005384fe6  0000000005384f56 
0000700001f14ce8:  000000000000010c  0000000005384fe6 
0000700001f14cf8:  0000700001f14d68  0000000005384f95 
0000700001f14d08: <00007fff7b771150  0000700001f15000 
0000700001f14d18:  0000700001f14d58  00000000056e2028 
0000700001f14d28:  00000000056e2000  000000000000010c 
0000700001f14d38:  0000000005384f56  0000700001f14d70 
0000700001f14d48:  00007fff7b58f312  0000700001f14d70 
0000700001f14d58:  00007fffffffffdf  ffffffff00000000 
0000700001f14d68:  0000000005384fe6  0000700001f14db0 
0000700001f14d78:  00007fff7b557368  000000c420a96000 
0000700001f14d88:  000000000570bfc0  ffffffffffffffff 
0000700001f14d98:  000000000000028f  0000000006500000 
0000700001f14da8:  0000000000000000  0000700001f14e00 
0000700001f14db8:  000000000477db08  0000700001f14df0 
0000700001f14dc8:  00007fff7b68b201  0000000000000028 
0000700001f14dd8:  0000000000000028  000000c420a95ed0 
0000700001f14de8:  ffffffffffffffff  000000c420a96000 
0000700001f14df8:  000000c420a95ed0  0000700001f14e30 
runtime: unknown pc 0x7fff7b632e3e
stack: frame={sp:0x700001f14d08, fp:0x0} stack=[0x700001e95290,0x700001f14e90)
0000700001f14c08:  0000000000000000  00007fff7b5b8e05 
0000700001f14c18:  00000000056e2000  0000000000000000 
0000700001f14c28:  00007fff7b5b8e64  0000700001f14c90 
0000700001f14c38:  00007fff7b7650d0  0000000000000000 
0000700001f14c48:  0000000000000000  00007fff7b5b8e05 
0000700001f14c58:  0000700001f14ca0  0000000000000002 
0000700001f14c68:  0000000005384fe6  0000000005384f95 
0000700001f14c78:  00000000056e2000  000000000000010c 
0000700001f14c88:  0000000005384f56  0000700001f14d70 
0000700001f14c98:  00007fff7b76507d  0000003000000030 
0000700001f14ca8:  0000700001f14d80  0000700001f14cc0 
0000700001f14cb8:  000000000000010c  0000000000000000 
0000700001f14cc8:  0000000005648a00  0000000005384f95 
0000700001f14cd8:  0000000005384fe6  0000000005384f56 
0000700001f14ce8:  000000000000010c  0000000005384fe6 
0000700001f14cf8:  0000700001f14d68  0000000005384f95 
0000700001f14d08: <00007fff7b771150  0000700001f15000 
0000700001f14d18:  0000700001f14d58  00000000056e2028 
0000700001f14d28:  00000000056e2000  000000000000010c 
0000700001f14d38:  0000000005384f56  0000700001f14d70 
0000700001f14d48:  00007fff7b58f312  0000700001f14d70 
0000700001f14d58:  00007fffffffffdf  ffffffff00000000 
0000700001f14d68:  0000000005384fe6  0000700001f14db0 
0000700001f14d78:  00007fff7b557368  000000c420a96000 
0000700001f14d88:  000000000570bfc0  ffffffffffffffff 
0000700001f14d98:  000000000000028f  0000000006500000 
0000700001f14da8:  0000000000000000  0000700001f14e00 
0000700001f14db8:  000000000477db08  0000700001f14df0 
0000700001f14dc8:  00007fff7b68b201  0000000000000028 
0000700001f14dd8:  0000000000000028  000000c420a95ed0 
0000700001f14de8:  ffffffffffffffff  000000c420a96000 
0000700001f14df8:  000000c420a95ed0  0000700001f14e30 

goroutine 5 [syscall]:
runtime.cgocall(0x477ca60, 0xc420a95ed0, 0x0)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/cgocall.go:128 +0x64 fp=0xc420a95e90 sp=0xc420a95e58 pc=0x4003954
github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools._Cfunc_Filter(0x0, 0x6500000, 0x0)
	_cgo_gotypes.go:107 +0x4a fp=0xc420a95ed0 sp=0xc420a95e90 pc=0x46f680a
github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools.Filter(0x0, 0x4a84dbc, 0x27, 0x0, 0x0, 0x0, 0x0, 0x0)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools/bindings.go:119 +0xbd fp=0xc420a95f48 sp=0xc420a95ed0 pc=0x46f79fd
github.com/src-d/gitbase/internal/function.TestBblfshFailing(0xc42025c2d0)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/internal/function/uast_test.go:408 +0x15e fp=0xc420a95fa8 sp=0xc420a95f48 pc=0x477911e
testing.tRunner(0xc42025c2d0, 0x4aa46b8)
	/usr/local/Cellar/go/1.10.1/libexec/src/testing/testing.go:777 +0xd0 fp=0xc420a95fd0 sp=0xc420a95fa8 pc=0x40ee6b0
runtime.goexit()
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc420a95fd8 sp=0xc420a95fd0 pc=0x405b121
created by testing.(*T).Run
	/usr/local/Cellar/go/1.10.1/libexec/src/testing/testing.go:824 +0x2e0

goroutine 1 [chan receive]:
testing.(*T).Run(0xc42025c2d0, 0x4a20124, 0x11, 0x4aa46b8, 0x407c801)
	/usr/local/Cellar/go/1.10.1/libexec/src/testing/testing.go:825 +0x301
testing.runTests.func1(0xc42025c1e0)
	/usr/local/Cellar/go/1.10.1/libexec/src/testing/testing.go:1063 +0x64
testing.tRunner(0xc42025c1e0, 0xc4201b3df8)
	/usr/local/Cellar/go/1.10.1/libexec/src/testing/testing.go:777 +0xd0
testing.runTests(0xc420a5a8e0, 0x53e0aa0, 0x6, 0x6, 0x4012919)
	/usr/local/Cellar/go/1.10.1/libexec/src/testing/testing.go:1061 +0x2c4
testing.(*M).Run(0xc420471080, 0x0)
	/usr/local/Cellar/go/1.10.1/libexec/src/testing/testing.go:978 +0x171
main.main()
	_testmain.go:52 +0x151

goroutine 6 [select]:
github.com/src-d/gitbase/vendor/google.golang.org/grpc.(*ccResolverWrapper).watcher(0xc420a319b0)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/google.golang.org/grpc/resolver_conn_wrapper.go:108 +0x182
created by github.com/src-d/gitbase/vendor/google.golang.org/grpc.(*ccResolverWrapper).start
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/google.golang.org/grpc/resolver_conn_wrapper.go:94 +0x3f

goroutine 7 [select]:
github.com/src-d/gitbase/vendor/google.golang.org/grpc.(*ccBalancerWrapper).watcher(0xc420031480)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/google.golang.org/grpc/balancer_conn_wrappers.go:122 +0x14a
created by github.com/src-d/gitbase/vendor/google.golang.org/grpc.newCCBalancerWrapper
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/google.golang.org/grpc/balancer_conn_wrappers.go:113 +0x14c

goroutine 8 [select]:
github.com/src-d/gitbase/vendor/google.golang.org/grpc.(*addrConn).transportMonitor(0xc420a9a000)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/google.golang.org/grpc/clientconn.go:1224 +0x235
github.com/src-d/gitbase/vendor/google.golang.org/grpc.(*addrConn).connect.func1(0xc420a9a000)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/google.golang.org/grpc/clientconn.go:827 +0x1b5
created by github.com/src-d/gitbase/vendor/google.golang.org/grpc.(*addrConn).connect
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/google.golang.org/grpc/clientconn.go:818 +0xe1

goroutine 36 [IO wait]:
internal/poll.runtime_pollWait(0x62e8f60, 0x72, 0xc420070bb8)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/netpoll.go:173 +0x57
internal/poll.(*pollDesc).wait(0xc420471218, 0x72, 0xffffffffffffff00, 0x4bb6660, 0x5386cc0)
	/usr/local/Cellar/go/1.10.1/libexec/src/internal/poll/fd_poll_runtime.go:85 +0x9b
internal/poll.(*pollDesc).waitRead(0xc420471218, 0xc420aa4000, 0x8000, 0x8000)
	/usr/local/Cellar/go/1.10.1/libexec/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc420471200, 0xc420aa4000, 0x8000, 0x8000, 0x0, 0x0, 0x0)
	/usr/local/Cellar/go/1.10.1/libexec/src/internal/poll/fd_unix.go:157 +0x1dc
net.(*netFD).Read(0xc420471200, 0xc420aa4000, 0x8000, 0x8000, 0x11, 0x0, 0x0)
	/usr/local/Cellar/go/1.10.1/libexec/src/net/fd_unix.go:202 +0x4f
net.(*conn).Read(0xc42000e008, 0xc420aa4000, 0x8000, 0x8000, 0x0, 0x0, 0x0)
	/usr/local/Cellar/go/1.10.1/libexec/src/net/net.go:176 +0x6a
bufio.(*Reader).Read(0xc420a9e060, 0xc420ab6038, 0x9, 0x9, 0x9, 0x0, 0x0)
	/usr/local/Cellar/go/1.10.1/libexec/src/bufio/bufio.go:216 +0x238
io.ReadAtLeast(0x4bb3ba0, 0xc420a9e060, 0xc420ab6038, 0x9, 0x9, 0x9, 0xc420070df0, 0x40028be, 0xc420070e9f)
	/usr/local/Cellar/go/1.10.1/libexec/src/io/io.go:309 +0x86
io.ReadFull(0x4bb3ba0, 0xc420a9e060, 0xc420ab6038, 0x9, 0x9, 0x45de75d, 0xc420a9c0ac, 0xc420044300)
	/usr/local/Cellar/go/1.10.1/libexec/src/io/io.go:327 +0x58
github.com/src-d/gitbase/vendor/golang.org/x/net/http2.readFrameHeader(0xc420ab6038, 0x9, 0x9, 0x4bb3ba0, 0xc420a9e060, 0x0, 0x0, 0x53ed660, 0xbec34e093548e55d)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/golang.org/x/net/http2/frame.go:237 +0x7b
github.com/src-d/gitbase/vendor/golang.org/x/net/http2.(*Framer).ReadFrame(0xc420ab6000, 0xc420a9c0a0, 0xc420a9c0a0, 0x0, 0x0)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/golang.org/x/net/http2/frame.go:492 +0xa4
github.com/src-d/gitbase/vendor/google.golang.org/grpc/transport.(*http2Client).reader(0xc42008ed80)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/google.golang.org/grpc/transport/http2_client.go:1195 +0xe1
created by github.com/src-d/gitbase/vendor/google.golang.org/grpc/transport.newHTTP2Client
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/google.golang.org/grpc/transport/http2_client.go:273 +0xbf1

goroutine 37 [select]:
github.com/src-d/gitbase/vendor/google.golang.org/grpc/transport.loopyWriter(0x4bc2840, 0xc420031540, 0xc420aa0180, 0xc420071fb8)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/google.golang.org/grpc/transport/transport.go:748 +0x368
github.com/src-d/gitbase/vendor/google.golang.org/grpc/transport.newHTTP2Client.func3(0xc42008ed80)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/google.golang.org/grpc/transport/http2_client.go:305 +0x5e
created by github.com/src-d/gitbase/vendor/google.golang.org/grpc/transport.newHTTP2Client
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/google.golang.org/grpc/transport/http2_client.go:304 +0xd42

rax    0x0
rbx    0x700001f15000
rcx    0x700001f14d08
rdx    0x0
rdi    0x2503
rsi    0x6
rbp    0x700001f14d40
rsp    0x700001f14d08
r8     0x0
r9     0x0
r10    0x0
r11    0x206
r12    0x2503
r13    0x56e2000
r14    0x6
r15    0x2d
rip    0x7fff7b632e3e
rflags 0x206
cs     0x7
fs     0x0
gs     0x0

And:

unexpected fault address 0xc4d000198bd
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x1 addr=0xc4d000198bd pc=0x4674363]

goroutine 5 [running]:
runtime.throw(0x4b67faf, 0x5)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/panic.go:616 +0x81 fp=0xc4221c95b0 sp=0xc4221c9590 pc=0x402d8b1
runtime.sigpanic()
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/signal_unix.go:395 +0x211 fp=0xc4221c9600 sp=0xc4221c95b0 pc=0x4042fb1
github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/sdk.v1/uast.(*Node).ProtoSize(0xc421226c40, 0x1)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/sdk.v1/uast/generated.pb.go:440 +0x53 fp=0xc4221c96f0 sp=0xc4221c9600 pc=0x4674363
github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/sdk.v1/uast.(*Node).ProtoSize(0xc420fd6460, 0x1)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/sdk.v1/uast/generated.pb.go:450 +0x91 fp=0xc4221c97e0 sp=0xc4221c96f0 pc=0x46743a1
github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/sdk.v1/uast.(*Node).ProtoSize(0xc420fd63f0, 0x2)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/sdk.v1/uast/generated.pb.go:450 +0x91 fp=0xc4221c98d0 sp=0xc4221c97e0 pc=0x46743a1
github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/sdk.v1/uast.(*Node).ProtoSize(0xc420fd6150, 0xc421674e00)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/sdk.v1/uast/generated.pb.go:450 +0x91 fp=0xc4221c99c0 sp=0xc4221c98d0 pc=0x46743a1
github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/sdk.v1/uast.(*Node).Marshal(0xc420fd6150, 0xc4221c9bc0, 0x49ab820, 0xc4216c6360, 0x0, 0x0)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/sdk.v1/uast/generated.pb.go:296 +0x2f fp=0xc4221c9a18 sp=0xc4221c99c0 pc=0x46733cf

And:

fatal error: concurrent map iteration and map write

goroutine 5 [running, locked to thread]:
runtime.throw(0x4c65d8f, 0x26)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/panic.go:616 +0x81 fp=0xc421387650 sp=0xc421387630 pc=0x402d961
runtime.mapiternext(0xc421387778)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/hashmap.go:747 +0x55c fp=0xc4213876e0 sp=0xc421387650 pc=0x400b8fc
runtime.mapiterinit(0x4a16ce0, 0xc4213e8562, 0xc421387778)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/hashmap.go:737 +0x1f1 fp=0xc421387708 sp=0xc4213876e0 pc=0x400b2b1
github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools.goGetPropertyKey(0xc421503f80, 0x0, 0xc421387820)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools/bindings.go:239 +0x79 fp=0xc4213877e8 sp=0xc421387708 pc=0x4899149
github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools._cgoexpwrap_c8b38fe99d54_goGetPropertyKey(0xc421503f80, 0x0, 0x0)
	_cgo_gotypes.go:340 +0x62 fp=0xc421387810 sp=0xc4213877e8 pc=0x4898382
runtime.call32(0x0, 0x70000a91e520, 0x70000a91e5b0, 0x18)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/asm_amd64.s:573 +0x3b fp=0xc421387840 sp=0xc421387810 pc=0x405908b
runtime.cgocallbackg1(0x0)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/cgocall.go:316 +0x19c fp=0xc4213878c0 sp=0xc421387840 pc=0x400441c
runtime.cgocallbackg(0x0)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/cgocall.go:194 +0xda fp=0xc421387928 sp=0xc4213878c0 pc=0x40041ea
runtime.cgocallback_gofunc(0x4004098, 0x490b980, 0xc4213879c8, 0x56c1480)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/asm_amd64.s:826 +0x9b fp=0xc421387948 sp=0xc421387928 pc=0x405a65b
runtime.asmcgocall(0x490b980, 0xc4213879c8)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/asm_amd64.s:673 +0x42 fp=0xc421387950 sp=0xc421387948 pc=0x405a4f2
runtime.cgocall(0x490b980, 0xc4213879c8, 0x0)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/cgocall.go:131 +0x88 fp=0xc421387988 sp=0xc421387950 pc=0x4004098
github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools._Cfunc_Filter(0xc4214ef030, 0x6bfbb00, 0x0)
	_cgo_gotypes.go:107 +0x4a fp=0xc4213879c8 sp=0xc421387988 pc=0x4897c8a
github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools.Filter(0xc4214ef030, 0xc420037d10, 0x27, 0x0, 0x0, 0x0, 0x0, 0x0)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/client-go.v2/tools/bindings.go:119 +0xbd fp=0xc421387a40 sp=0xc4213879c8 pc=0x4898e7d

And:

unexpected fault address 0xb01dfacedebac1e
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb01dfacedebac1e pc=0x400b83a]

goroutine 22 [running]:
runtime.throw(0x4b67faf, 0x5)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/panic.go:616 +0x81 fp=0xc42102b700 sp=0xc42102b6e0 pc=0x402d961
runtime.sigpanic()
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/signal_unix.go:395 +0x211 fp=0xc42102b750 sp=0xc42102b700 pc=0x4043061
runtime.evacuated(...)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/hashmap.go:198
runtime.mapiternext(0xc42102b888)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/hashmap.go:771 +0x49a fp=0xc42102b7e0 sp=0xc42102b750 pc=0x400b83a
runtime.mapiterinit(0x4a16ce0, 0xc4214d9b80, 0xc42102b888)
	/usr/local/Cellar/go/1.10.1/libexec/src/runtime/hashmap.go:737 +0x1f1 fp=0xc42102b808 sp=0xc42102b7e0 pc=0x400b2b1
github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/sdk.v1/uast.(*Node).ProtoSize(0xc420b21500, 0x1)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/sdk.v1/uast/generated.pb.go:441 +0x2b5 fp=0xc42102b8f8 sp=0xc42102b808 pc=0x4674675
github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/sdk.v1/uast.(*Node).ProtoSize(0xc42162f570, 0x16)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/sdk.v1/uast/generated.pb.go:450 +0x91 fp=0xc42102b9e8 sp=0xc42102b8f8 pc=0x4674451
github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/sdk.v1/uast.(*Node).Marshal(0xc42162f570, 0x0, 0x16, 0xc42121e2c0, 0x0, 0x16)
	/Users/erizocosmico/go/src/github.com/src-d/gitbase/vendor/gopkg.in/bblfsh/sdk.v1/uast/generated.pb.go:296 +0x2f fp=0xc42102ba40 sp=0xc42102b9e8 pc=0x467347f

can't pin sdk version using dep anymore

recently Gopkg.toml was introduced to client-go

which cause an error if I try to pin sdk version in my project:

$ dep ensure
Solving failure: No versions of gopkg.in/bblfsh/client-go.v2 met constraints:
	v2.8.2: Could not introduce gopkg.in/bblfsh/[email protected], as it has a dependency on gopkg.in/bblfsh/sdk.v2 with constraint v2, which has no overlap with existing constraint ^2.0.1 from (root)
	v2.8.1: Could not introduce gopkg.in/bblfsh/[email protected], as it is not allowed by constraint ^2.8.2 from project github.com/bblfsh/web.
	v2.8.0: Could not introduce gopkg.in/bblfsh/[email protected], as it is not allowed by constraint ^2.8.2 from project github.com/bblfsh/web.
	v2.7.0: Could not introduce gopkg.in/bblfsh/[email protected], as it is not allowed by constraint ^2.8.2 from project github.com/bblfsh/web.
	v2.6.2: Could not introduce gopkg.in/bblfsh/[email protected], as it is not allowed by constraint ^2.8.2 from project github.com/bblfsh/web.
	v2.6.1: Could not introduce gopkg.in/bblfsh/[email protected], as it is not allowed by constraint ^2.8.2 from project github.com/bblfsh/web.
	v2.6.0: Could not introduce gopkg.in/bblfsh/[email protected], as it is not allowed by constraint ^2.8.2 from project github.com/bblfsh/web.
	v2.5.2: Could not introduce gopkg.in/bblfsh/[email protected], as it is not allowed by constraint ^2.8.2 from project github.com/bblfsh/web.
	v2.5.1: Could not introduce gopkg.in/bblfsh/[email protected], as it is not allowed by constraint ^2.8.2 from project github.com/bblfsh/web.
	v2.5.0: Could not introduce gopkg.in/bblfsh/[email protected], as it is not allowed by constraint ^2.8.2 from project github.com/bblfsh/web.
	v2.4.3: Could not introduce gopkg.in/bblfsh/[email protected], as it is not allowed by constraint ^2.8.2 from project github.com/bblfsh/web.
	v2.4.2: Could not introduce gopkg.in/bblfsh/[email protected], as it is not allowed by constraint ^2.8.2 from project github.com/bblfsh/web.
	v2.4.1: Could not introduce gopkg.in/bblfsh/[email protected], as it is not allowed by constraint ^2.8.2 from project github.com/bblfsh/web.
	v2.4.0: Could not introduce gopkg.in/bblfsh/[email protected], as it is not allowed by constraint ^2.8.2 from project github.com/bblfsh/web.
	v2.3.1: Could not introduce gopkg.in/bblfsh/[email protected], as it is not allowed by constraint ^2.8.2 from project github.com/bblfsh/web.
	v2.3.0: Could not introduce gopkg.in/bblfsh/[email protected], as it is not allowed by constraint ^2.8.2 from project github.com/bblfsh/web.
	v2.2.3: Could not introduce gopkg.in/bblfsh/[email protected], as it is not allowed by constraint ^2.8.2 from project github.com/bblfsh/web.
	v2.2.2: Could not introduce gopkg.in/bblfsh/[email protected], as it is not allowed by constraint ^2.8.2 from project github.com/bblfsh/web.
	v2.2.1: Could not introduce gopkg.in/bblfsh/[email protected], as it is not allowed by constraint ^2.8.2 from project github.com/bblfsh/web.
	v2.2.0: Could not introduce gopkg.in/bblfsh/[email protected], as it is not allowed by constraint ^2.8.2 from project github.com/bblfsh/web.
	v2.1.0: Could not introduce gopkg.in/bblfsh/[email protected], as it is not allowed by constraint ^2.8.2 from project github.com/bblfsh/web.
	v2.0.0: Could not introduce gopkg.in/bblfsh/[email protected], as it is not allowed by constraint ^2.8.2 from project github.com/bblfsh/web.

Gopkg.toml:

[prune]
  go-tests = true
  unused-packages = true
  non-go = true

  [[prune.project]]
    name = "gopkg.in/bblfsh/client-go.v2"
    non-go = false

[[constraint]]
  name = "gopkg.in/bblfsh/sdk.v2"
  version = "^2.0.1"

[[constraint]]
  name = "gopkg.in/bblfsh/client-go.v2"
  version = "^2.8.2"

Removing constraint for sdk doesn't help also (dep resolves it to ^2.0.0 automatically because it's used in source code).

The only way to make dep happy I found: use override for sdk.

Context deadline exceeded parsing csharp

Not sure if it's a C# driver, client-go or bblfshd issue so I just opened it here.

I'm using this script:

package main

import (
	"fmt"

	bblfsh "gopkg.in/bblfsh/client-go.v3"
)

const code = `
using System.Net;
using System.Net.Http.Headers;
using System.Net.Sockets;
using Microsoft.AspNetCore.Http;

namespace ProxyKit
{
    public static class XForwardedExtensions
    {
        public const string XForwardedFor = "X-Forwarded-For";
        public const string XForwardedHost = "X-Forwarded-Host";
        public const string XForwardedProto = "X-Forwarded-Proto";
        public const string XForwardedPathBase = "X-Forwarded-PathBase";

        /// <summary>
        ///     Applies X-Forwarded.* headers to the outgoing
        ///     header collection.
        /// </summary>
        /// <param name="outgoingHeaders">The outgoing HTTP request
        /// headers.</param>
        /// <param name="for">The client IP address.</param>
        /// <param name="host">The host of the request.</param>
        /// <param name="proto">The protocol of the incoming request.</param>
        public static void ApplyXForwardedHeaders(
            this HttpRequestHeaders outgoingHeaders,
            IPAddress @for,
            HostString host,
            string proto) 
            => ApplyXForwardedHeaders(outgoingHeaders, @for, host, proto, string.Empty);

        /// <summary>
        ///     Applies X-Forwarded.* headers to the outgoing header collection
        ///     with an additional PathBase parameter.
        /// </summary>
        /// <param name="outgoingHeaders">The outgoing HTTP request
        /// headers.</param>
        /// <param name="for">The client IP address.</param>
        /// <param name="host">The host of the request.</param>
        /// <param name="proto">The protocol of the incoming request.</param>
        /// <param name="pathBase">The base path of the incoming
        /// request.</param>
        public static void ApplyXForwardedHeaders(
            this HttpRequestHeaders outgoingHeaders,
            IPAddress @for,
            HostString host,
            string proto,
            PathString pathBase)
        {
            if (@for != null)
            {
                var forString = @for.AddressFamily == AddressFamily.InterNetworkV6
                    ? $"\"[{@for}]\""
                    : @for.ToString();
                outgoingHeaders.Add(XForwardedFor, forString);
            }

            if (host.HasValue)
            {
                outgoingHeaders.Add(XForwardedHost, host.Value);
            }

            if (!string.IsNullOrWhiteSpace(proto))
            {
                outgoingHeaders.Add(XForwardedProto, proto);
            }

            if (!string.IsNullOrWhiteSpace(pathBase))
            {
                outgoingHeaders.Add(XForwardedPathBase, pathBase);
            }
        }
    }
}
`

func main() {
	client, err := bblfsh.NewClient("0.0.0.0:9432")
	if err != nil {
		panic(err)
	}

	res, _, err := client.NewParseRequest().
		Language("csharp").
		Content(code).
		UAST()
	if err != nil {
		panic(err)
	}

	fmt.Println(res)
}

I'm running v2.11.0-drivers on a container and installed v0.2.0 of csharp driver.

Logs are:

time="2019-01-28T13:35:20Z" level=info msg="bblfshd version: v2.11.0 (build: 2018-12-12T23:31:48+0000)"
time="2019-01-28T13:35:20Z" level=info msg="initializing runtime at /var/lib/bblfshd"
time="2019-01-28T13:35:20Z" level=info msg="server listening in 0.0.0.0:9432 (tcp)"
time="2019-01-28T13:35:20Z" level=info msg="control server listening in /var/run/bblfshctl.sock (unix)"
time="2019-01-28T13:44:39Z" level=info msg="driver csharp installed "bblfsh/csharp-driver:v0.2.0""
time="2019-01-28T13:50:51Z" level=error msg="error selecting pool: unexpected error: context deadline exceeded"
time="2019-01-28T13:50:51Z" level=error msg="request processed content 2690 bytes error: unexpected error: context deadline exceeded" elapsed=5.2095507s language=csharp
time="2019-01-28T13:50:51Z" level=info msg="csharp-driver version: v0.2.0 (build: 2019-01-22T15:05:36Z)" id=01d2abm1kf0bgmhfjm8d1zz8j1 language=csharp
time="2019-01-28T13:50:51Z" level=info msg="server listening in /tmp/rpc.sock (unix)" id=01d2abm1kf0bgmhfjm8d1zz8j1 language=csharp
time="2019-01-28T13:51:37Z" level=warning msg="unable to allocate a driver instance: context deadline exceeded" language=csharp
time="2019-01-28T13:51:37Z" level=error msg="request processed content 2690 bytes error: context deadline exceeded" elapsed=5.0032111s language=csharp

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.