Whats a good best practice with Go workspaces?

后端 未结 10 1381
南方客
南方客 2021-01-30 10:46

I\'m just getting into learning Go, and reading through existing code to learn \"how others are doing it\". In doing so, the use of a go \"workspace\", especially as it relates

10条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-30 11:18

    I used to use multiple GOPATHs -- dozens, in fact. Switching between projects and maintaining the dependencies was a lot harder, because pulling in a useful update in one workspace required that I do it in the others, and sometimes I'd forget, and scratch my head, wondering why that dependency works in one project but not another. Fiasco.

    I now have just one GOPATH and I actually put all my dev projects - Go or not - within it. With one central workspace, I can still keep each project in its own git repository (src/) and use git branching to manage dependencies when necessary (in practice, very seldom).

    My recommendation: use just one workspace, or maybe two (like if you need to keep, for example, work and personal code more separate, though the recommended package path naming convention should do that for you).

提交回复
热议问题