To resolve the issue you encountered while setting up Go in Mac OS X 10.10, you can follow the steps outlined below. First, ensure that the GOROOT variable points to the directory where Go is installed, rather than the executable itself. This can be done using the command:
Furthermore, $PATH should include the path to the GOROOT/bin directory.
It's worth noting that in certain cases, setting GOROOT is not necessary. Reference the article "You don't need to set GOROOT, really" for additional information.
Regarding GOPATH, it should point to a directory containing src, pkg, and bin subdirectories, not directly to the src folder. Refer to "How to Write Go Code - Workspace" for further clarification.
You can try the following steps:
It's important to avoid using "sudo go get," as the environment variables employed for sudo (root) may differ from those for the current user. Instead, simply use:
By following these steps, you should be able to overcome the issue and effectively use Go in your Mac OS X 10.10 environment. Remember, it's essential to have a proper understanding of GOPATH and its role in Go development.
The above is the detailed content of How to Set GOPATH in Mac OS X 10.10 for Go Development?. For more information, please follow other related articles on the PHP Chinese website!