Home >Backend Development >Golang >Go Modules: All-or-Nothing Transition from GOPATH?
When migrating internal codebases from dep to go modules, certain considerations arise. This article delves into the expectations and consequences of using go modules, particularly in relation to private repositories and the gopath.
Go Modules and the Gopath
According to the Go project architects, "dotless" paths (without a preceding dot) are intended exclusively for the standard library. Internally developed dependencies should not use this notation.
Once a project transitions to using go modules, it must fully embrace the module system. The gopath then becomes functionally identical to a module cache.
Consequences of Modules and Private Repos
This transition to modules necessitates managing dependencies through private repositories. Consequently, developers may face the following consequences:
Your Key Assumption
Your assumption that all dependencies in a go module project must be resolved through the module system is correct. The gopath serves solely as a cache for downloaded modules.
Question: Are go modules all-or-nothing?
Yes, go modules are all-or-nothing. Once a project adopts modules, all dependencies must be modularized. The gopath only retains its significance as a cache for downloaded modules.
Resolving Dependencies Explciitly from the Gopath
There is no way to explicitly indicate that a dependency should be resolved from the gopath.
Additional Insights
The above is the detailed content of Go Modules: All-or-Nothing Transition from GOPATH?. For more information, please follow other related articles on the PHP Chinese website!