Credits to the Go Example project https://go.googlesource.com/example for the example code to analyze Please refer to the golangci-lint documentation for for its installation
$ git clone https://github.com/sylvain-combe-sonarsource/import-golintci-lint
$ cd import-golintci-lint
$ golangci-lint run
The provided (./.golangci.yaml) configuration file is only provided as an example. The file does not represent a list of linters that Sonar would recommend to use.
Position the SonarQube(or SonarCloud) Server URL, analysis token, and SonarCloud organization before you run the scanner command. As described with External analyzer reports | SonarQube Docs, golangci-lint is configured to output its report in CheckStyle format, and Sonar analysis is configured to pickup this output from the reports folder.
$ export SONAR_TOKEN="YOUR-SONARQUBE-OR-SONARCLOUD-ANALYSIS-TOKEN"
$ export SONAR_URL="https://sonarqube.mycompany.com/"
$ sonar-scanner