duanjian9148 2016-12-26 17:15
浏览 60
已采纳

Intellij上的Golang插件。 库和断点

I write my code on Go. I build my project in Idea Intellij with plugin for golang. I have a package main. In main import different packages.

import (
    "RF"
    "flag"
    "io"
    "net/http"
    "os"
    "runtime"
    "depot"
    "info"
    "logger"
    "logic"
    "poly"
    "ranker"
    "revgeocoder"
    "search"
    "search/engine"
    "stat"
    "views"
    "fmt"
)

This packages very well linked if I write paths in $GOPATH. In Idea Intellij it makes such way:

Path to packages

Now, I want:

  1. Build my project without warning
  2. Debugging my project

First point. I make a 'build' and than I have: "Package is not specified"

Package is not specified

If I write to Package name main, than warning doesn't disappear:

Cannot find package <code>main</code>

What I can do?


Point number two. The assembly is successful. After that part of package I can debug, another package I cannot debug. For example package engine I can debug. Path to this package:

/home/INT.PV.KM/urvanov/hedgehogues/distr/mapsfullsearch/src/search/engine/engine.go

Next file I cannot debug.

/home/INT.PV.KM/urvanov/hedgehogues/distr/mapsfullsearch/src/search/context.go

Tree of catalog

I cannot set a breaks point in this file:

Break point

Please, help me with my problems.

  • 写回答

2条回答 默认 最新

  • duan7772 2016-12-30 11:43
    关注

    The answer to the first question

    Any project in Go consist of packages. There is nothing except for packages. All packages are located in the same directory, which one is project. Other directories are libraries. They set through environment variable $GOPATH. IDEA IntelliJ let make it as:

    File->Settings:

    Outer packages

    There are two type of libs in Go: globals and locals. You read about this here.

    In the build time is necessary to specify which package we want to gather and line up all the dependencies themselves. In my project, there are n packets. For example, I can build mapsfullsearch package. I can build mfsimporter package. Or I can build any other, in which there is func main () {/*...*/}. To build just specify the appropriate configuration.

    After that, all Imports (if relevant packages exist), resolved.

    Struct of my project

    About configurations. Go to Run -> Edit Configurations...

    Settings of configurations

    Name: name of compilled file. Run kind: which type of building (file or package). Package: package name that matches the name of the directory in which the main(). There are drop-down list in IDEA IntelliJ. It appears, if you start to write his name. Output directory: directory where the binary. Environments: variables of environments Go Tool arguments: compiler's arguments Program arguments: program's arguments

    For more information about config can be read here.

    The answer to the second question

    In the IDEA may be poorly specified file path. In that case, to which I referred in her question, the problem was related to the fact that the path to the library is specified via the home directory, which is denoted by ~. IDEA does not perceive such format. Repeat this problem I did not succeed. Although up to the moment until I put the project in the root file system, my project didn't work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择