英文:
MinGW installed in windows but still throwing error in while go run
问题
我最初在运行Go语言服务器代码时遇到了错误,错误出现在代码的导入行中:
import (
"encoding/json"
"fmt"
"log"
"github.com/confluentinc/confluent-kafka-go/kafka"
)
错误提示要检查%PATH%变量中是否存在可执行的gcc:
# github.com/confluentinc/confluent-kafka-go/kafka
cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in %PATH%
为了解决这个问题,我安装了MinGW gcc编译器并将其添加到了路径中,在终端中进行了检查:
g++ (tdm64-1) 10.3.0
版权所有 (C) 2020 Free Software Foundation, Inc.
这是自由软件;请参阅源代码以了解复制条件。没有任何保证;甚至没有适用于特定目的的适应性保证。
这仍然导致相同的错误,请问有人可以告诉我如何在Windows 10中解决这个问题。
编辑:
通过重新启动终端解决了这个问题。问题在于即使重新启动了Visual Studio Code中的终端,路径变量仍未设置,所以我只能使用普通的PowerShell来运行脚本。
英文:
I was initially facing the error during running a server code for go lang and the error in the import lines of the code
import (
"encoding/json"
"fmt"
"log"
"github.com/confluentinc/confluent-kafka-go/kafka")
The error it was thrown was to check for executable gcc in the %PATH% variable
# github.com/confluentinc/confluent-kafka-go/kafka
cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in %PATH%
To rectify this i have installed MinGW gcc compiler and include in the path
Checked it in the terminal
g++ (tdm64-1) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
This throwing the same error can anyone please tell me how to rectify this in windows 10.
EDIT:
This was resolved by restarting the terminal
The issue was even after restarting the terminal in Visual code the path variable was not set so just used plain old powershell to run the script.
答案1
得分: 0
这个问题通过重新启动终端解决了。即使在 Visual Studio Code 中重新启动终端后,路径变量仍未设置,所以只需使用普通的 PowerShell 运行脚本即可。
英文:
This was resolved by restarting the terminal The issue was even after restarting the terminal in Visual code the path variable was not set so just used plain old powershell to run the script.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论