SONAR-scanner can't file index .go in win10

SonarQube 7.2.1
SonarQube Scanner 3.2.0.1227
Java 1.8.0_121 Oracle Corporation (64-bit)
Windows 10 10.0 amd64
go version go1.10.3 windows/amd64

My sonar-project.properties

 sonar.projectKey=vendor
 sonar.projectName=Fisrt Test
 sonar.projectVersion=1.0
 sonar.sources=.
 sonar.inclusions=**/*.go
 sonar.exclusions=**/*_test.go
 sonar.sourceEncoding=UTF-8

When I run sonar-scanner.bat


0 files indexed

How can I do this?

Hello,

your sonar.inclusions property should be like **/*.go , to allow indexing Go source files in subdirectories. Same for sonar.exclusions

Sorry, I noticed on the screenshot that you are actually setting the properties the way I suggest, it was only improperly formatted in your message.

Can you post your actual directory structure?

thank for you reply

$ pwd
/i/goWork/src/vendor/moservice/lib/vast

$ ls
duration.go       extension_test.go  offset_test.go            testdata/
duration_test.go  LICENSE            README.md                 vast.go
extension.go      offset.go          sonar-project.properties  vast_test.go

I guess the dir path can’t has the name VENDOR.

There isn’t any such restriction. I would recommend getting debug logs (sonar.verbose=true) and checking the output: you’ll get a precise view of which files are seen/considered/indexed.

In fact @weijian_ni you are right, vendor directory is excluded by default, because we expect that you don’t want to analyze dependencies of your project (they should be analyzed separately in their own project).

You can change that behavior by un-setting sonar.go.exclusions property, just set it to empty value. I am going to update our documentation about this.

1 Like

I stand corrected :open_mouth: Sorry for the initial mislead @weijian_ni, I didn’t realize there was a default exclusion hardcoded.