Troubleshooting GOPATH Configuration on Mac OS X 10.10
When setting up Go development on Mac OS X 10.10, users may encounter issues related to GOPATH configuration. This article provides guidance on resolving these problems and establishing the correct environment variables.
Setting GOROOT and PATH
GOROOT should point to the directory where Go is installed, not the executable itself. Correctly set it as follows:
export GOROOT=/usr/local/go export PATH=$PATH:$GOROOT/bin
Setting GOPATH
GOPATH should reference a folder containing src, pkg, and bin directories. It should not directly reference the src folder. For example:
export GOPATH=/Users/USERNAME/Documents/GoProjects
Bash Configuration
Add the GOPATH setting to your ~/.bashrc file using export. Ensure that you are using a bash shell by verifying the output of 'echo $SHELL'.
Go Environment Variables
Use 'go env' to check the current values of Go environment variables, including GOPATH.
Avoid Sudo
Do not use 'sudo go get' as the environment variables set for the root user (sudo) will not be the same as those for your current user. Instead, execute:
go get github.com/gocql/gocql
Additional Notes:
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3