Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go workspace vs custom folder structure

Tags:

go

I'm currently learning Go, and I have learned that Go suggests (expects? enforces?) that you use a specific folder layout for your workspace:

- my-go-workspace
  - src
  - bin
  - pkg

I perfectly understand the reasoning for this, and I definitely see its advantages. So, basically, I think it's a good thing to have a structure like this.

The only thing I don't like about this, is that it is a completely different structure from my other projects. E.g., for my Node.js projects there is a folder such as this:

- projects
  - moduleA
  - moduleB
  - ...

Now if I want to keep Node.js modules and Go packages side-by-side, in a unified folder structure I either have to use Go's way for Node.js as well (which feels wrong), or vice-versa (which feels wrong either).

I guess it's probably a dumb idea, and I should simply stick with Go's suggestion and live with two different ways of organizing my code (hey, it's different languages, why should the folder layout be the same?), but somehow this does not feel clean to me.

I know that this a highly subjective and personal, but my question is, if there are any practices out there on how to solve this? Or should I just live with it?

like image 991
Golo Roden Avatar asked Mar 18 '23 18:03

Golo Roden


1 Answers

A more simple idea:

golos-projects
 L node-project-a
    L what
    L ever
    L yolo
 L node-project-b
    L we
    L love
    L npm
 L go-project-a
    L src
    L pkg
    L bin
 L go-project-b
    L src
    L pkg
    L bin

And just set your GOPATH to e.g. golos-projects/go-project-b and hack away. When you want to switch to another project just change your GOPATH to the new project's folder.

like image 128
thwd Avatar answered Mar 28 '23 19:03

thwd