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:
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.
/home/florin/go
and full path $GOPATH/src/github.com/dlsniper/demo
. Alternatively, you can use the Run Kind
directory and point it to the directory or simply just use the green arrow near the func main
, click on it, select Run ...
and then select Go Application
Run Configuration
of type Go Application
to run the application then to debug it you'll just need to use the Debug option instead of Run. Alternatively, you can click on the green arrow near the func main
and choose Debug...
to debug your application. 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 arguments
For more information about config can be read here .
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.