Wednesday, August 31, 2022

[SOLVED] MinGW installed in windows but still throwing error in while go run

Issue

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.


Solution

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.



Answered By - Mohammad Siraj
Answer Checked By - Gilberto Lyons (WPSolving Admin)