【Go新手起步01】5步完成 vscode的go插件安装跟激活。

发布时间 2023-05-16 19:04:45作者: Asa_wl

 

  1. 首先下载vscode,进行两个插件安装,如图所示

     

  2. 然后下载go语言,在官网https://go.dev/doc/install下载

     

    cmd打开,输入go version验证下载是否成功。

  3. 在dos页面输入

    go env -w GO111MODULE=on                 go env -w GOPROXY=https://goproxy.cn,direct

     

  4. 在vscode中间的输入窗口输入:

    • 输入go,找到Go:Install/Update Tools并点击

    • 会弹出一个列表,全选,再点击OK

       

    注意不要使用代理,不然下载不成功。

     

     

  5. 运行一个helloworld.go程序进行测试

     

    报错如下:

    Build Error: go build -o e:\0code\vscode\__deb go: go.mod file not found in current directory or any parent directory; see 'go help modules' (exit status 1)

    上网搜索了解决方法https://zhidao.baidu.com/question/1613646304621437147.html

    在命令行窗口中进行输入:go env -w GO111MODULE=auto

     

    程序正常运行了。