Create default folders for new Go Projects?

There is a convention for structuring go projects with certain subfolders such as 
/pkg
/src
/test
/doc

etc etc.

I find myself creating these directories by hand for every new Go Project, and was wondering if there was a way to create this everytime a new Go Project is created using GoLand?

0
3 comments

Hi Francis,

 

There is no such convention available. The Go Workspace (aka GOPATH), requires just "bin/", "src/", "pkg/" dirs to be present, but only "src/" is really needed in order for the workspace to exist, the others are created automatically by the "go" tool on the first run.

A single Go Workspace (GOPATH) can be used to host many different projects, not just a single one, and multiple entries can exist under the GOPATH environment variable. And since a single Go Workspace can contain multiple projects, which can have any layout they want, I'm not sure what's the best way to move forward on this.

Do you use a single GOPATH per project and the project share nothing between them?

However, to answer your question, no, it's currently not possible to define custom project structure, see this issue for details.

 

Thank you.

1

I have multiple projects in their respective directories underneath the GOPATH. 

Thanks for the detailed and prompt response

0

Hi Francis,

 

I see. Then I guess you are using a custom project setup.
I think the issue linked is what should solve the issue.


Kind regards,
Florin

0

Please sign in to leave a comment.