![](/img/trans.png)
[英]Import C error in Golang: cc1.exe: error: too many filenames given
[英]gosec giving “could not import C (no metadata for C)” golang error
我在我的項目上運行 gosec 但它給出了以下錯誤,因為我們的管道失敗了
文件中的 Golang 錯誤:[/home/usr/exmaple/project.go]:
[第 22 行:第 8 列] - 無法導入 C(沒有 C 的元數據)
而 go 構建命令成功構建項目意味着沒有 golang 錯誤。
這不是問題。
We found out that our C code is present in.c and.h files in package directory, where.h file containing only function prototypes. 我們在 go 文件 (cgo) 中包含 only.h 文件。
go build and go test commands are working because both of these commands when see.c and.h in package directory, compiles and link them. But gosec is a SAST tool, it doesn't compile.c and.h files present in package directory due to this gosec scan was getting only function prototypes not definition and was throwing Golang error could not import C (no metadata for C).
在注釋中包含整個代碼 (CGO) 有效。 現在 gosec 工作正常。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.