Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The term 'go' is not recognized as the name of a cmdlet, function, script file, or operable program

After running...

go run main.go

I get this error

go : The term 'go' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
like image 707
Travis Rivera Avatar asked Feb 03 '18 21:02

Travis Rivera


People also ask

Is not recognized as the name of a cmdlet function script file?

Check for Missing Modules in PowerShell If the module is missing or damaged, PowerShell won't be able to execute it. By default, you have to install modules in the exact order to use them. If that module is missing, corrupt, or got moved, it throws up the error, “the term is not recognized as the name of a cmdlet.”

Is not recognized as the name of a cmdlet function script file in Vscode?

If you see the error "The term 'cl.exe' is not recognized as the name of a cmdlet, function, script file, or operable program.", this usually means you are running VS Code outside of a Developer Command Prompt for Visual Studio and VS Code doesn't know the path to the cl.exe compiler.


2 Answers

SOLVED: Go to visual studio code (assuming this is installed) ctrl + shift + p to open command window type

Go: current GOPATH

this should give you a path create a system environment variable named GOPATH and add that path into that variable.

Make sure the system environment variables are set to:

GOPATH is set (in my case) to C:\Users[username]\go

GOROOT is set to C:\go\

IDE is Visual Studio Code.

like image 116
Travis Rivera Avatar answered Nov 05 '22 04:11

Travis Rivera


$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")

write the code to the terminal and run it. Eazy way to solve the problem.

like image 44
Mcan_Cicek Avatar answered Nov 05 '22 04:11

Mcan_Cicek