mac wsdl2java_Mac Golang开发环境搭建

本文记录了在Mac上通过Homebrew安装和配置Golang环境的过程,包括选择并安装go@1.10版本,设置GOPATH和相关环境变量,并验证了安装成功。同时,提到了该环境适用于进行go语言项目开发,特别是结合wsdl2java的使用。
摘要由CSDN通过智能技术生成

由于需要进行go语言项目的开发,基于自己个人的Mac电脑做了一些开发环境的配置,本文旨在做一个简单的记录。

先介绍下本文的电脑配置:

3e2b4f80df88

image.png

一、安装brew

Homebrew有点类似于Linux操作系统中的apt-get(Ubuntu)、yum(yum),Mac的操作系统中使用它解决包依赖问题,套用官方的话来说:

让我们开始安装吧!

在命令行输入以下指令

fabric:~ fabric$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

出现以下内容,安装成功

==> Installation successful!

==> Homebrew has enabled anonymous aggregate user behaviour analytics.

Read the analytics documentation (and how to opt-out) here:

https://docs.brew.sh/Analytics.html

==> Next steps:

- Run `brew help` to get started

- Further documentation:

https://docs.brew.sh

二、安装并配置golang

首先看看有哪些golang版本可用

louxiujun@IT-C02Z9057LVDL  /usr/local/opt  brew search go

==> Formulae

algol68g google-java-format

anycable-go google-sparsehash

arangodb google-sql-tool

argon2 googler

aws-google-auth goolabs

bogofilter goose

cargo-completion gopass

certigo gor

cgoban goreleaser

clingo goreman

django-completion gost

forego gosu

fuego gotags

gnu-go goto

go gource

go-bindata govc

go-jira govendor

go-md2man gowsdl

go-statik gox

go@1.10 ✔ gst-plugins-good

go@1.11 gx-go

go@1.12 hugo

go@1.9 jfrog-cli-go

goaccess jpegoptim

goad lego

gobby lgogdownloader

gobject-introspection libgosu

gobuster mongo-c-driver

gocr mongo-cxx-driver

gocryptfs mongo-orchestration

godep mongoose

goenv pango

gofabric8 pangomm

goffice protoc-gen-go

golang-migrate pygobject

gollum pygobject3

golo ringojs

gom spaceinvaders-go

gomplate spigot

goocanvas svgo

goofys wego

google-authenticator-libpam wireguard-go

google-benchmark write-good

==> Casks

homebrew/cask-fonts/font-go

homebrew/cask-fonts/font-go-medium

homebrew/cask-fonts/font-go-mono

homebrew/cask-fonts/font-go-mono-nerd-font

homebrew/cask-fonts/font-go-mono-nerd-font-mono

homebrew/cask/go-agent

homebrew/cask/go-server

选择一个自己想要的版本,这里本人选择的是go@1.10版本。

安装brew下go@1.10版本:

louxiujun@IT-C02Z9057LVDL  $ brew install go@1.10

Updating Homebrew...

==> Downloading https://homebrew.bintray.com/bottles/go@1.9-1.9.7.high_sierra.bottle.tar.gz

######################################################################## 100.0%

==> Pouring go@1.9-1.9.7.high_sierra.bottle.tar.gz

==> Caveats

A valid GOPATH is required to use the `go get` command.

If $GOPATH is not specified, $HOME/go will be used by default:

https://golang.org/doc/code.html#GOPATH

You may wish to add the GOROOT-based install location to your PATH:

export PATH=$PATH:/usr/local/opt/go@1.10/libexec/bin

This formula is keg-only, which means it was not symlinked into /usr/local,

because this is an alternate version of another formula.

If you need to have this software first in your PATH run:

echo 'export PATH="/usr/local/opt/go@1.9/bin:$PATH"' >> ~/.bash_profile

==> Summary

/usr/local/Cellar/go@1.10/1.9.7: 7,668 files, 294.2MB

确认一下go@1.10的安装目录:

louxiujun@IT-C02Z9057LVDL  $ cd /usr/local/opt/

louxiujun@IT-C02Z9057LVDL  $ ls

gettext go@1.10 libidn2 libunistring openssl@1.1 wget

可以看到二进制的go@1.10已经被安装在该目录下了。

配置golang的相关环境变量

louxiujun@IT-C02Z9057LVDL  $ vim ~/.bashrc

将下面内容添加进上面的文件

#GOROOT

export GOROOT=/usr/local/opt/go\@1.10

#GOPATH

export GOPATH=$HOME/Documents/code/gopath

#GOPATH root bin

export PATH=$PATH:$GOROOT/bin

GOPATH可以根据个人习惯设置为其他目录。本人习惯在home目录下的Documents里新建一个code目录,用于存放各种语言的代码,例如:Documents/code/gopath用于存放golang的代码,Documents/code/java用于存放java代码等。

让改动立即生效:

louxiujun@IT-C02Z9057LVDL  $ source ~/.bashrc

试一试golang是否安装成功

出现以下内容,则安装成功

louxiujun@IT-C02Z9057LVDL  /usr/local/opt  go env

GOARCH="amd64"

GOBIN=""

GOCACHE="/Users/louxiujun/Library/Caches/go-build"

GOEXE=""

GOHOSTARCH="amd64"

GOHOSTOS="darwin"

GOOS="darwin"

GOPATH="/Users/louxiujun/Documents/code/gopath"

GORACE=""

GOROOT="/usr/local/opt/go@1.10"

GOTMPDIR=""

GOTOOLDIR="/usr/local/opt/go@1.10/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/2h/43trw35142g1h7qs8zdgxbn40000gp/T/go-build985605356=/tmp/go-build -gno-record-gcc-switches -fno-common"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值