简体   繁体   English

使用 VSCODE 运行 go 不起作用

[英]Run go with VSCODE is not working

i've installed the latest go (I saw the go outout with go -v in the command line )我已经安装了最新的 go(我在命令行中看到了 go -v 的 go outout )

I've installed go plugins to vs code and restart and create some simple file like following我已经将 go plugins 安装到 vs code 并重新启动并创建了一些简单的文件,如下所示

main.go main.go

package main

import (
    "fmt"
)

func main() {

    fmt.Println("hello world");
}

when I run it (with run option plugin , click on file and run) I got error in the console当我运行它时(使用运行选项插件,单击文件并运行)我在控制台中出现错误

[Running] go run "/Users/i076777/GoProjects/GoProjTest/main.go"
/bin/sh: go: command not found

Any idea what Im missing here ?知道我在这里缺少什么吗?

I've also try the following which doesnt work Ive MAC and I see in env GOROOT="/usr/local/go" and I use 'export PATH=$PATH:/usr/local/go/' and its not working.我还尝试了以下不起作用的方法 Ive MAC 并且我在 env GOROOT="/usr/local/go"看到并且我使用了'export PATH=$PATH:/usr/local/go/'并且它不起作用。

You are missing go in your path it looks like.你错过了它看起来像的路径。 Check with echo $PATH and you should have :/c/Go/bin: in it somewhere (or the folder you installed go to).检查 echo $PATH ,你应该有:/c/Go/bin:在它的某个地方(或你安装的文件夹去)。

As a side test, open a command prompt / shell and type go env - if it is in your path you should get your go environment variables showing - if they do appear, please update the question.作为辅助测试,打开命令提示符/shell 并输入go env - 如果它在您的路径中,您应该显示您的 go 环境变量 - 如果它们确实出现,请更新问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM