Home >Backend Development >Golang >Why Does 'go get' Fail with 'can't load package: package .: no buildable Go source files'?
Troubleshooting "can't load package: package .: no buildable Go source files" Error
When attempting to retrieve a Go package using "go get," you may encounter the error message "can't load package: package .: no buildable Go source files." To troubleshoot this issue, ensure you are executing the command from the source directory of your Go project, e.g., "/Users/7yan00/Golang/src/myProject."
Alternatively, try using the "-d" (download-only) option with "go get." This instructs the command to download the package without installing it. Run the following command:
go get -d
If the issue persists, consider whether you are using "go get" correctly. It is intended for retrieving specific packages, not entire repositories. To obtain a specific package, specify its URL as follows:
go get code.google.com/p/go.text/encoding
To retrieve all packages from a repository, use the "..." notation:
go get code.google.com/p/go.text/...
The above is the detailed content of Why Does 'go get' Fail with 'can't load package: package .: no buildable Go source files'?. For more information, please follow other related articles on the PHP Chinese website!