2019-03-31 07:54
浏览 619


I am new in golang.

i can not start my go file in VSCODE ,my code is simple

package main

import "fmt"

func main() {

when i run go run main.go in my terminal every thing works fine but when i save it in my vscode i get too many errors all like

/work/src/ encoding/xml.Name composite literal uses unkeyed fields

my main.go file located at /work

how can i solve the problem ?

图片转代码服务由CSDN问答提供 功能建议


我无法启动我的go文件 在VSCODE中,我的代码很简单

import“ fmt” 
func main(){
 fmt.Println(“ test”)

当我在终端中运行 go main.go 时,一切正常,但是当我将其保存在vscode中时,我得到了 太多错误,例如

/work/src/ / xml。名称复合文字使用无键字段

我的main.go文件位于/ work


  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douhuo3696 2019-03-31 11:40

    It looks to me like you've installed/unarchived Go at /work, which I assume is your home directory.

    As a result, when you try and build your program which is also in /work (rather than use go run from the command line), all of the code underneath the /work directory where your main.go file are also being checked by VS Code.

    The simplest solution might be to put your main.go file outside the work directory completely, or put it within the Go path at /work/src/<your_username>/<your_package>.

    解决 无用
    打赏 举报

相关推荐 更多相似问题