VSCode import "C" 在模块上失败
VSCode import "C" fails on modules
请看下面的截图:
它说:
could not import C (no package data for import path C)
我在此处附上了一个重现失败的示例项目:https://github.com/microsoft/vscode/files/3783446/example-project.zip
我正在使用 Go 1.13 以及 Go 和 C/C++ 的每个扩展的最新版本。
没有编译器错误,这看起来特别孤立为 "vscode problem".
有没有办法解决这个 vscode 问题?
问题是导入之间多了一个新行,你可以试试下面的方法:
// #cgo CFLAGS: -g -Wall
// #include <stdio.h>
// #include <stdlib.h>
// #include <string.h>
// #include "cutils.h"
import "C"
import (
"bufio"
"encoding/json"
// ...
)
在这里查看与 CGO 相关的其他示例:
https://github.com/alessiosavi/GoUtils/blob/master/GoUtils.go
这是 VSCode 的一个错误,我已经针对这个问题写了一篇中型文章。
https://medium.com/@mourya.g9/setting-up-confluent-kafka-client-for-golang-with-vscode-7a27bb94220b。希望这有帮助。
这是官方 golang 包中分发的 gopls
工具中的错误。
问题链接如下:
来自问题报告的信息:
internal/lsp: use Go/cgo source files instead of generated files
Using CompiledGoFiles was causing metadata lookups to fail for cgo
packages because it includes generated files in the Go build cache
when the built-in 'go list' driver is used. GoFiles includes both
Go and cgo original file names, allowing metadata lookups to
succeed.
请看下面的截图:
它说:
could not import C (no package data for import path C)
我在此处附上了一个重现失败的示例项目:https://github.com/microsoft/vscode/files/3783446/example-project.zip
我正在使用 Go 1.13 以及 Go 和 C/C++ 的每个扩展的最新版本。 没有编译器错误,这看起来特别孤立为 "vscode problem".
有没有办法解决这个 vscode 问题?
问题是导入之间多了一个新行,你可以试试下面的方法:
// #cgo CFLAGS: -g -Wall
// #include <stdio.h>
// #include <stdlib.h>
// #include <string.h>
// #include "cutils.h"
import "C"
import (
"bufio"
"encoding/json"
// ...
)
https://github.com/alessiosavi/GoUtils/blob/master/GoUtils.go
这是 VSCode 的一个错误,我已经针对这个问题写了一篇中型文章。
https://medium.com/@mourya.g9/setting-up-confluent-kafka-client-for-golang-with-vscode-7a27bb94220b。希望这有帮助。
这是官方 golang 包中分发的 gopls
工具中的错误。
问题链接如下:
来自问题报告的信息:
internal/lsp: use Go/cgo source files instead of generated files
Using CompiledGoFiles was causing metadata lookups to fail for cgo
packages because it includes generated files in the Go build cache
when the built-in 'go list' driver is used. GoFiles includes both
Go and cgo original file names, allowing metadata lookups to
succeed.