D
D
danforth2016-12-23 20:00:39
go
danforth, 2016-12-23 20:00:39

How to manage multiple Go projects without getting confused with folders and imports?

Hello!
I'm new to Go. Now I write under Windows (only in terms of convenience and comfort), sometimes I compile under a Linux virtual machine to see how it behaves.
The crux of the matter:
Let's say Go itself is installed in C:\Go, and I keep projects in C:\apps\go\. So, I needed to create a new project, let's call it supertool. I create a folder and get C:\apps\go\supertool\. Question #1: Should the main file of this application be called main.go? Next, inside this application, I want to make a package. That is, my supertool will have a superpackage. I create a folder and a file C:\apps\go\supertool\superpackage\superpackage.gowhere I declare package superpackage(or package supertool/superpackage?). Next, from the main package file, I need to import this package, I do ... oops, here's the hitch,Question number 2: How to import it? If you enter import "superpackage"it, it will not compile, and it should not. And finally, Question number 3: How to manage several different projects / programs in Go, so that everything is convenient and in folders? Does anyone have a tree of his directories with many projects?
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pavlyuk, 2016-12-23
@pav5000

Store your projects in $GOPATH (C:\Go\src\supertool\) Put
specific package dependencies in C:\Go\src\supertool\vendor Put
your project packages in the project folder C:\Go\src\supertool\superpackage
Collect this whole thing later through go build supertool

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question