GO in IntelliJ IDEA. Multiple File and Error Undefined: Data

前端 未结 4 2160
你的背包
你的背包 2021-02-02 17:25

I want use IntelliJ IDE Community Edition to write code in GO (GoLang). I instaled right plugin, and instaled all need tools to build applicati

4条回答
  •  轮回少年
    2021-02-02 17:58

    Let say you are having a project with src/ sub directory and two .go files inside: hello.go and typetest.go and both defines the same package "main". One of them (hello.go) also implements func main().

    To make it compile as whole you need to make sure two things are configured properly: GOPATH and Run/Debug configuration.

    Open the Project Libraries/GOPATH settings:

    For Gogland

    File -> Settings -> Go

    For Intellij IDEA

    File -> Settings -> Languages & Frameworks -> Go -> Go Libraries

    Makes sure the GOPATH for the project looks something like that:

    GOPATH settings

    Next, open Run -> Edit Configurations and make sure your configuration looks similar to this:

    Run/Debug configuration

提交回复
热议问题