You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/detectors/go.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,10 +22,11 @@ Improved go detection depends on the following to successfully run:
22
22
23
23
- Go v1.11+.
24
24
25
-
Go detection is performed by parsing output from executing `go mod graph`.
26
25
Full dependency graph generation is supported if Go v1.11+ is present on the build agent.
27
26
If no Go v1.11+ is present, fallback detection strategy is performed.
28
27
28
+
Go detection is performed by parsing output from executing [go list -m -json all](1). To generate the graph, the command [go mod graph](2) is executed, this only adds edges between the components that were already registered by `go list`.
29
+
29
30
As we validate this opt-in behavior, we will eventually graduate it to the default detection strategy.
30
31
31
32
## Known limitations
@@ -35,11 +36,14 @@ Dev dependency tagging is not supported.
35
36
Go detection will fallback if no Go v1.11+ is present.
36
37
37
38
Due to the nature of `go.sum` containing references for all dependencies, including historical, no-longer-needed dependencies; the fallback strategy can result in over detection.
38
-
Executing `go mod tidy` before detection via fallback is encouraged.
39
+
Executing [go mod tidy](https://go.dev/ref/mod#go-mod-tidy) before detection via fallback is encouraged.
40
+
41
+
Some legacy dependencies may report stale transitive dependencies in their manifests, in this case you can remove them safely from your binaries by using [exclude directive](https://go.dev/doc/modules/gomod-ref#exclude).
39
42
40
43
## Environment Variables
41
44
42
-
If the environment variable `EnableGoCliScan` is set, to any value, the Go detector uses [`go mod graph`][1] to discover Go dependencies.
45
+
If the environment variable `EnableGoCliScan` is set, to any value, the Go detector uses [`go list -m -json all`][1] to discover Go dependencies.
43
46
If the environment variable is not present, we fall back to parsing `go.mod` and `go.sum` ourselves.
| Gradle | <ul><li>*.lockfile</li></ul> | <ul><li>Gradle 7 or prior using [Single File lock](https://docs.gradle.org/6.8.1/userguide/dependency_locking.html#single_lock_file_per_project)</li></ul> | ❌ | ❌ |
9
-
| Go | <ul><li>*go mod graph*</li></ul>Fallback</br><ul><li>go.mod</li><li>go.sum</li></ul> | <ul><li>Go 1.11+ (will fallback if not present)</li></ul> | ❌ | ✔ (root idenditication only for fallback) |
9
+
| Go | <ul><li>*go list -m -json all*</li><li>*go mod graph* (edge information only)</li></ul>Fallback</br><ul><li>go.mod</li><li>go.sum</li></ul> | <ul><li>Go 1.11+ (will fallback if not present)</li></ul> | ❌ | ✔ (root idenditication only for fallback) |
| NPM | <ul><li>package.json</li><li>package-lock.json</li><li>npm-shrinkwrap.json</li><li>lerna.json</li></ul> | - | ✔ (dev-dependencies in package.json, dev flag in package-lock.json) | ✔ |
0 commit comments