A
A
Anton Mashletov2017-09-23 13:50:30
go
Anton Mashletov, 2017-09-23 13:50:30

GOPATH in mixed projects?

Just started learning Go. According to the manual, GOPATH should refer to the workspace, where the source code of packages (both one's own and others') will be stored in the src folder. My main language is PHP / C ++ and I have long been accustomed to the structure of one folder - one project. Without language division: /Projects/CompanyX/ProjectNameX. Go, on the other hand, suggests creating another folder with its own structure. In addition, the main project will be located in one place, and only Go - in another. This is just a blow to my perfectionism :) It would be convenient for me, for example: /Projects/freelance/site1/services/GoModule.
Question. Is it correct when working with a Go project in the IDE to switch GOPATH to this particular workspace? I prefer one project - one workspace.
PS: I already asked a similar question here, but in the past I didn’t formulate it that way.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
longclaps, 2017-09-23
@mashletov

I answered, I'll try again)
I use the Gogland IDE from JenBrains (late pre-release beta, still available for free), and I'm not worried - it drives for me. The menu has the following settings:

  • File -> Default settings -> Global GOPATH, Project GOPATH, "Use GOPATH from sys env" checkbox
  • File -> Project settings -> Global GOPATH, Project GOPATH, checkbox "Use GOPATH from sys env", Module GOPATH
  • Run -> Edit conf -> File, Output dir, Working dir
For educational purposes, it was enough for me to specify the Project GOPATH for the sources, what all these settings for the go-infrastructure are translated into - I did not delve into it, but it is there)

F
f22, 2017-09-23
@f22

Can be stored in the vendor subdirectory
https://blog.gopheracademy.com/advent-2015/vendor-...

N
Nikita, 2017-09-23
@bitver

The project can be anywhere.
Downloaded packages will get into GOPATH and it is also convenient to throw off your individual packages, tools, projects, etc. there, so that you can import and use from any project.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question