Importing Local Packages Without GOPATH
Importing local packages without GOPATH can be achieved by following the steps provided below:
Go Dependency Management Summary:
Before proceeding, it's important to note that the preferred Go dependency management approach depends on the Go version being used:
vgo (Go 1.11 and above):
Vendor (Go 1.6 and above):
Create a "vendor" directory in the project and place dependent packages within it. Upon compilation, the compiler will prioritize packages from the vendor directory.
Found: Import Local Packages Using Subfolders (GOPATH)
To import local packages using GOPATH and subfolders:
Example project structure:
myproject/ ├── binary1.go ├── binary2.go ├── package1/ │ └── package1.go └── package2.go
Additional Notes:
The above is the detailed content of How Can I Import Local Packages in Go Without Using GOPATH?. For more information, please follow other related articles on the PHP Chinese website!