最近刚买了macbook,学习一下强大的包管理工具,homebrew


安装brew

brew官网,复制脚本执行即可,可以说是非常方便了

安装java

1. 使用brew安装

执行命令

brew cask install java

安装之后的是最新版java 10 ,目录是这个:

/Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home

2. 官网安装历史版本

java官网下载1.8版本

安装之后的目录:

/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home

安装Go

1. 使用brew安装

执行命令

brew install go

安装之后的目录

/usr/local/Cellar/go/1.10.1

2. 配置GOPATH

echo "export GOPATH=/Users/caobo/Project/GoProject" >> ~/.bash_profile
echo "export GOBIN=$GOPATH/bin" >> ~/.bash_profile
echo "export PATH=$PATH:$GOBIN" >> ~/.bash_profile
source ~/.bash_profile

然后通过 go env来查看结果

go env
GOARCH="amd64"
GOBIN="/Users/caobo/Project/GoProject/bin"
GOCACHE="/Users/caobo/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/caobo/Project/GoProject"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.10.1/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.10.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/b3/4t07smdd74l7z9pyr_rr2m300000gn/T/go-build553699271=/tmp/go-build -gno-record-gcc-switches -fno-common"

安装开发工具 vscode

使用brew安装

brew cask install visual-studio-code

然后就可以使用spotlight或者code命令打开

vscode