'go' is not recognized as an internal or external command

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
3 min

banner

# 'go' is not recognized as an internal or external command

The error "'go' is not recognized as an internal or external command, operable program or batch file" occurs for 2 main reasons:

  1. Not having Go installed on your machine.
  2. Not having the path to the go executable in your system's PATH environment variable.

go is not recognized as internal or external command

To install and configure Go:

  1. Visit the official Downloads Page and click on the "Download Go for Windows" button.

download go for windows

  1. When you start the installer, you might have to change your app recommendation settings.

change my app recommendation settings

  1. You can set the "Choose where to get apps" value to "Anywhere, but warn me before installing an app that's not from the Microsoft Store".

choose where to get apps

  1. Click on "Install anyway".

click install anyway

  1. Click the "Next" button on the Welcome screen.

start installer click-next

  1. Tick the checkbox to accept the license agreement and click "Next".

accept go license agreement

  1. Leave the default destination folder selected and click "Next".

go select default destination location

  1. Click on the "Install" button.

go click install

  1. Wait for the installation to complete and click "Finish".

go installation complete

Make sure to close and reopen Command Prompt, PowerShell and your IDE (e.g. Visual Studio Code).

In a new Command Prompt, issue the go version command to make sure go is installed and in your PATH.

cmd
go version

go command works

If you still get the error that "'go' is not recognized as an internal or external command", you have to add the path to the go executable to your system's PATH environment variable.

The default location of the go.exe file is in the following directory.

cmd
C:\Program Files\Go\bin # 👇️ Might also be under Program Files (x86) C:\Program Files (x86)\Go\bin

path to go executable

# Add the path to the go executable in your system's PATH environment variable

To add the path to the go executable in your system's PATH environment variable:

  1. Click on the Search bar and type "environment variables".
  2. Click on "Edit the system environment variables".

edit system environment variables

  1. Click on the "Environment Variables" button.

click environment variables

  1. In the "System variables" section, select the "Path" variable and click "Edit".

select path and click edit

  1. You can either click "New" and then "Browse" and navigate to the path or paste it directly.

click new browse

The path on my machine is the following:

cmd
C:\Program Files\Go\bin # 👇️ might also be under Program Files (x86) C:\Program Files (x86)\Go\bin

If you can't find the PATH, try issuing the where go command.

where go command

We are looking for the directory that contains the go.exe file because this is the file that is run when you issue go commands.

path to go executable

  1. Once you find the path to your go executable file, add it and click on the "OK" button twice to confirm.

added path to go executable

  1. Close your Command prompt application and then reopen it.
Note that you must restart your Command prompt shell for the changes to take effect.

You might also have to restart your PC, but that's not always necessary.

In a new Command Prompt, issue the go version command to make sure go is installed and in your PATH.

cmd
go version

go command works

After the path to the executable (go.exe) has been added to your system's PATH environment variable, the go command should work.

If you got the error in Visual Studio Code and restarting VSCode doesn't help, try to click on the trash bin button to restart the terminal.

restart vscode terminal

If the error persists, try restarting your PC to make sure you don't have any stale CMD, PowerShell or IDE sessions and rerun the go version command.

# Conclusion

The solve the error "'go' is not recognized as an internal or external command, operable program or batch file", make sure:

  1. You have Go installed on your machine.
  2. You have the path to the go executable in your system's PATH environment variable.
I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.