Go

Configuration - .deepsource.toml

This section covers configuration specific to the go analyzer. Please make sure to read the general configuration guide first.

name

  • Type: String
  • Presence: mandatory
  • Description: Shortcode of the analyzer.
  • Example:
name = "go"

enabled

  • Type: Boolean
  • Presence: mandatory
  • Description: Toggle whether this analyzer should be run.
  • Example:
enabled = true

meta

  • Type: Table
  • Presence: mandatory
  • Description: Any supported metadata to pass to the analyzer.
  • Example:
[analyzers.meta]
  import_paths = ["github.com/deepsourcelabs/web-app/backend"]

import_paths

  • Type: Array
  • Presence: optional
  • Description: The Go analyzer by default automatically populates import_paths by searching for any available package managers. To override this behavior, all the import paths in the repository should be mentioned in this array.
  • Default Value: None
  • Example:
import_paths = ["github.com/deepsourcelabs/web-app/backend"]

import_root

  • Type: String
  • Presence: mandatory
  • Description: Repository source code will be placed in $GOPATH/src/{import_root}. If you haven't yet migrated to Go Modules, you should configure import_root properly so that dependencies can be fetched for analysis.
  • Default Value: None
  • Example:
import_root = "github.com/deepsourcelabs/web-app"

skip_doc_coverage

  • Type: Array
  • Presence: optional
  • Description: Specify which artifacts to skip when calculating documentation coverage.
  • Available Value: file
    • file - Do not include file docs while calculating documentation coverage.
  • Default Value: None
  • Example:
skip_doc_coverage = ["file"]

dependencies_vendored

  • Type: Boolean
  • Presence: optional
  • Description: If set to true the analyzer doesn't install dependencies since they are already available in the vendor directory of the repository.
  • Available Values: true, false
  • Default Value: false
  • Example:
[analyzers.meta]
dependencies_vendored = true

build_tags

  • Type: Array
  • Presence: optional
  • Description: Specify the build tags with which the analyzer can determine whether a file should be included in the package. This prevents compilation-related issues due to the inclusion/exclusion of files based on tags (or constraints).
  • Default Value: None
  • Example:
build_tags = ["darwin"]

cgo_enabled

  • Type: Boolean
  • Presence: optional
  • Description: Whether the analyzed packages will call C code using CGo. If the C code relies on external C libraries, they might not be present for analysis runs resulting in analysis failure. If your project does not use CGo, set the flag to false.
  • Available Values: true, false
  • Default Value: true
  • Example:
cgo_enabled = false

[DEPRECATED] import_path

  • Type: String
  • Presence: mandatory if import_paths is empty
  • Description: The import path of the repository should be mentioned in this string.
  • Default Value: None
  • Example:
import_path = "github.com/deepsourcelabs/web-app/backend"
`import_path` is now deprecated. It will still be used if the `import_paths` array is empty, for backward compatibility. It is recommended to configure `import_root` and let the analyzer automatically figure out the `import_paths` instead of using this field.

Sample config

version = 1

test_patterns = [
  "tests/*_test.go",
  "**/*_test.go"
]

[[analyzers]]
name = "go"
enabled = true

  [analyzers.meta]
  import_root = "github.com/deepsourcelabs/web-app"
  dependencies_vendored = false
  build_tags = ["darwin"]
  cgo_enabled = false

Package managers

DeepSource installs your dependencies to get a complete picture of your code for in-depth analysis. Our analyzer automatically detects the package manager used. We support the following package managers:

FilenamePackage Manager
go.modgo modules
Gopkg.lockdep
GLOCKFILEglock
Godeps/Godeps.jsongodep
dependencies.tsvgodeps
glide.lockglide
vendor.conftrash
trash.yamltrash
vendor/manifestgvt
vendor/vendor.jsongovendor
No dependency fileNo deps installed

If the meta property dependencies_vendored is set to true, dependency installation is skipped.