diff --git a/analyzer/src/funTest/assets/projects/synthetic/gomod-dangling-embed-expected-output.yml b/analyzer/src/funTest/assets/projects/synthetic/gomod-dangling-embed-expected-output.yml new file mode 100644 index 0000000000000..88ad2f2cd0e52 --- /dev/null +++ b/analyzer/src/funTest/assets/projects/synthetic/gomod-dangling-embed-expected-output.yml @@ -0,0 +1,23 @@ +--- +project: + id: "GoMod::gomod_dangling_embed:" + definition_file_path: "analyzer/src/funTest/assets/projects/synthetic/gomod-dangling-embed/go.mod" + declared_licenses: [] + declared_licenses_processed: {} + vcs: + type: "Git" + url: "" + revision: "" + path: "" + vcs_processed: + type: "Git" + url: "" + revision: "" + path: "" + homepage_url: "" + scopes: + - name: "main" + dependencies: [] + - name: "vendor" + dependencies: [] +packages: [] diff --git a/analyzer/src/funTest/assets/projects/synthetic/gomod-dangling-embed/go.mod b/analyzer/src/funTest/assets/projects/synthetic/gomod-dangling-embed/go.mod new file mode 100644 index 0000000000000..9df283ceff15a --- /dev/null +++ b/analyzer/src/funTest/assets/projects/synthetic/gomod-dangling-embed/go.mod @@ -0,0 +1,3 @@ +module gomod_dangling_embed + +go 1.19 diff --git a/analyzer/src/funTest/assets/projects/synthetic/gomod-dangling-embed/main.go b/analyzer/src/funTest/assets/projects/synthetic/gomod-dangling-embed/main.go new file mode 100644 index 0000000000000..55363ec8a9ebd --- /dev/null +++ b/analyzer/src/funTest/assets/projects/synthetic/gomod-dangling-embed/main.go @@ -0,0 +1,17 @@ +package main + +import ( + _ "embed" + "fmt" +) + +//go:generate touch file.txt +var( + //go:embed file.txt + file string +) + +func main() { + fmt.Println(file) + fmt.Println("hello world") +} diff --git a/analyzer/src/funTest/kotlin/managers/GoModFunTest.kt b/analyzer/src/funTest/kotlin/managers/GoModFunTest.kt index 9bd5e5b9d0930..adb4d9075f23d 100644 --- a/analyzer/src/funTest/kotlin/managers/GoModFunTest.kt +++ b/analyzer/src/funTest/kotlin/managers/GoModFunTest.kt @@ -82,4 +82,13 @@ class GoModFunTest : StringSpec({ result.toYaml() should matchExpectedResult(expectedResultFile, definitionFile) } + + "Source files with dangling embed directives do not yield issues" { + val definitionFile = testDir.resolve("gomod-dangling-embed/go.mod") + val expectedResultFile = testDir.resolve("gomod-dangling-embed-expected-output.yml") + + val result = create("GoMod").resolveSingleProject(definitionFile) + + result.toYaml() should matchExpectedResult(expectedResultFile, definitionFile) + } }) diff --git a/analyzer/src/main/kotlin/managers/GoMod.kt b/analyzer/src/main/kotlin/managers/GoMod.kt index 3b7ea6ae3c8d1..befe8806cd12a 100644 --- a/analyzer/src/main/kotlin/managers/GoMod.kt +++ b/analyzer/src/main/kotlin/managers/GoMod.kt @@ -100,7 +100,7 @@ class GoMod( override fun transformVersion(output: String) = output.removePrefix("go version go").substringBefore(' ') - override fun getVersionRequirement(): RangesList = RangesListFactory.create(">=1.19.0") + override fun getVersionRequirement(): RangesList = RangesListFactory.create(">=1.21.1") override fun mapDefinitionFiles(definitionFiles: List): List = definitionFiles.filterNot { definitionFile ->