-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(analyzer): Add a test for dangling embed directives / GoMod
The `GoMod` integration does not execute `go generate/go build`, so the embed directive in `main.go` points to a non-existing file. When `GoMod` executes [1] it failed [2] with the previously used Go version 1.20.5. As of [3], with Go version 1.21.1, that issue is fixed. Add a test to ensure it keeps on working. Note: It is essential to pass `json=Module` instead of not just `-json` [4], because otherwise the issue would still persist on Go 1.21.1. So, [3] and [4] together fix [5]. Fixes #5560. [1] `go list -deps -json=Module -buildvcs=false ./...` [2] `pattern file.txt: no matching` [3] 47e4520 [4] 43ad3a7 [5] #5560. Signed-off-by: Frank Viernau <[email protected]>
- Loading branch information
Showing
4 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
analyzer/src/funTest/assets/projects/synthetic/gomod-dangling-embed-expected-output.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
project: | ||
id: "GoMod::gomod_dangling_embed:<REPLACE_REVISION>" | ||
definition_file_path: "analyzer/src/funTest/assets/projects/synthetic/gomod-dangling-embed/go.mod" | ||
declared_licenses: [] | ||
declared_licenses_processed: {} | ||
vcs: | ||
type: "Git" | ||
url: "<REPLACE_URL_PROCESSED>" | ||
revision: "<REPLACE_REVISION>" | ||
path: "<REPLACE_PATH>" | ||
vcs_processed: | ||
type: "Git" | ||
url: "<REPLACE_URL_PROCESSED>" | ||
revision: "<REPLACE_REVISION>" | ||
path: "<REPLACE_PATH>" | ||
homepage_url: "" | ||
scopes: | ||
- name: "main" | ||
dependencies: [] | ||
- name: "vendor" | ||
dependencies: [] | ||
packages: [] |
3 changes: 3 additions & 0 deletions
3
analyzer/src/funTest/assets/projects/synthetic/gomod-dangling-embed/go.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module gomod_dangling_embed | ||
|
||
go 1.19 |
17 changes: 17 additions & 0 deletions
17
analyzer/src/funTest/assets/projects/synthetic/gomod-dangling-embed/main.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters