from Hacker News

Ask HN: Organizing Golang and non-Golang projects?

by rxlim on 12/24/16, 4:22 PM with 1 comments

For many years I have organized my projects in a single directory like this:

  |-- projects
      |-- project_0
      |-- project_1
      |-- project_2
A project regardless of programming language will get a directory under 'projects', that contains all files releated to this particular project.

Some time ago I started learning Golang and have since written many utilities in it as I like it very much. Golang requires a special directory layout for all it's tools to work, and this layout is incompatible with the one I'm using.

What is the best way to organize Golang and non-Golang projects? Should I just bite the bullet and start organizing my projects by language?

  • by christophberger on 12/24/16, 11:27 PM

    You could use a Go "project" that is in fact the $GOPATH, like so:

        |-- projects
              |-- project_0
              |-- project_1
              |-- project_2
              |-- go
                   |-- src 
                   |-- pkg 
                   |-- bin
              |-- project_4
              |-- project_5
    
    
    Your other projects would then not be affected at all.

    Or consider using a tool like `gb` (https://github.com/constabulary/gb) that does not depend on $GOPATH. (But ensure to understand the caveats of this tool before switching to it.)