Skip to content

Latest commit

 

History

History
76 lines (47 loc) · 1.72 KB

README.md

File metadata and controls

76 lines (47 loc) · 1.72 KB

sonar-go-to-slang

Generate slang serialized AST in JSON from a go source file.

Building

The entire build process can be done with the make.sh script. The following command will download Go of the required version and build the project:

./make.sh build

Individual build steps are described below.

To generate goparser_generated.go file in current directory, run:

go generate

To create sonar-go-to-slang executable in current directory, run:

go build

To create sonar-go-to-slang executable in $GOPATH/bin, run:

go install

Building on Windows

When trying to build sonar-go-to-slang on Windows, the build may fail with the following error:

Create symbolic link at [...]\slang\sonar-go-to-slang.gogradle\project_gopath\src\github.com\SonarSource\slang\sonar-go-to-slang failed

Creating the symbolic link by hand solves this problem:

     mklink /D ".gogradle\project_gopath\src\github.com\SonarSource\slang\sonar-go-to-slang" "Absolute\Path\To\slang\sonar-go-to-slang"

Running

If you have $GOPATH/bin on your PATH, it's easy to run with slang-generator-go.

Run with -h or -help or --help to get usage help.

Print the SLANG Json tree for some source.go:

sonar-go-to-slang source.go

Dump the native raw AST for some source.go:

sonar-go-to-slang -d source.go

Testing

To perform the tests, run:

go test

To update expected test data, use the method fix_all_go_files_test_automatically in goparser_test.go.