Where to add custom packages

Hello do i need to have my custom packages in GOPATH or inside the project? for example im creating and API do i need to have the routes in the project folder or in GOPATH?

Aren’t those “routes” part of your project?

Anyway, assuming the modern way of using Go modules, the GOPATH should remain free of sourcecode unless dealing with legacy projects.

Yeah the routes ar part of the project, so you mean GOPATH is only for packages that i install with go get?

I mean, if you do not currently develop your project in the GOPATH, then you do not need to care for the GOPATH at all.

If you have a go.mod at your project root, then the GOPATH is irrelevant for you.

If you do not have such a file at your project root, your project already lives in the GOPATH, and your routes/subpackages should live below your project root anyway, as you want to have them in the same repository, don’t you?

Though if this is true and you develop legacy style in the GOPATH, you should convert your project to a new style go module and move it out of the GOPATH.

1 Like

O i get it , thanks a lot men.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.