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:
Now, I want:
- Build my project without warning
- Debugging my project
First point. I make a 'build' and than I have: "Package is not specified"
If I write to Package name main
, than warning doesn't disappear:
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
I cannot set a breaks point in this file:
Please, help me with my problems.
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:
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.
About configurations. Go to Run -> Edit 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 argumentsFor 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.