转自 http://www.kelvinwong.ca/2009/11/12/installing-google-go-on-mac-os-x-leopard/
To get started, make sure that you have Python and Mercurial installed on your Intel Mac (PowerPC is not supported at this point). Also make sure that you have XCode installed and that you are attached to the Internet (the test suite will need Internet access to run a few tests).
Trinity:~ kelvin$ python -V
Python 2.5.2
Trinity:~ kelvin$ hg version
Mercurial Distributed SCM (version 1.0.1)
Copyright (C) 2005-2008 Matt Mackall <mpm@selenic.com> and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Trinity:~ kelvin$ xcodebuild -version
Xcode 3.1.2
Component versions: DevToolsCore-1148.0; DevToolsSupport-1102.0
BuildVersion: 9M2621
Trinity:~ kelvin$ uname -p
i386
Trinity:~ kelvin$
Okay, now we’re going to make some environment variables that Go will use to compile your code. In my home directory, I put the following variables into the ‘.bash_profile’ file:
#GOROOT="/usr/local/go"
#GOBIN=""
#GOARCH="386"
#GOCHAR="8"
#GOOS="darwin"
#GOEXE=""
#GOHOSTARCH="386"
#GOHOSTOS="darwin"
#GOTOOLDIR="/usr/local/go/pkg/tool/darwin_386"
#GOGCCFLAGS="-g -O2 -fPIC -m32 -pthread -fno-common"
#CGO_ENABLED="1"
# Google Go Lang Vars
export GOROOT=$HOME/go
export GOOS=darwin
export GOARCH=386
export GOBIN=$HOME/bin
export PATH=$GOBIN:$PATH
Now we make sure that the environment has the variables we just set up:
Trinity:~ kelvin$ source .bash_profile
Trinity:~ kelvin$ env | grep ^GO
GOBIN=/Users/kelvin/bin
GOARCH=386
GOROOT=/Users/kelvin/go
GOOS=darwin
Trinity:~ kelvin$
Make sure that your ‘~/go’ directory doesn’t exist since the next command will make it into a Mercurial repository. We will be creating the ‘~/bin’ directory after we create the repository.
$ cd go/src
$ hg pull
$ hg update release
$ ./all.bash
或者 Trinity:~ kelvin$ hg clone -r release https://go.googlecode.com/hg/ $GOROOT
requesting all changes
adding changesets
adding manifests
adding file changes
added 3976 changesets with 16799 changes to 2931 files
updating working directory
1640 files updated, 0 files merged, 0 files removed, 0 files unresolved
Trinity:~ kelvin$ cd $GOROOT
Trinity:go kelvin$ ls
AUTHORS LICENSE doc include misc src
CONTRIBUTORS README favicon.ico lib pkg test
Trinity:go kelvin$ cd src/
Trinity:src kelvin$
Okay, so far we have set-up the environment and the respository. Now would be a good time to ensure the ‘~/bin’ folder actually exists. In many cases, it is already there. If it isn’t there, you need to create it and mark it executable (Hint: Try ‘mkdir ~/bin’ then ‘chmod 755 ~/bin’).
Trinity:src kelvin$ test -e ~/bin && echo 'bin exists'
bin exists
Trinity:src kelvin$
Okay, now we’re ready to build Go.
Trinity:src kelvin$ ./all.bash
rm -f *.o *.6 6.out lib9.a
rm -f bbuffered.o bfildes.o bflush.o bgetc.o bgetrune.o bgetd.o binit.o boffset.o bprint.o bputc.o bputrune.o brdline.o brdstr.o bread.o bseek.o bwrite.o *.6 6.out libbio.a
rm -f *.o *.so
.... holy crap there is a lot of output here...
./mkasmh.sh >386/asm.h.x
mv -f 386/asm.h.x 386/asm.h
8a 386/asm.s
8c -Idarwin -Idarwin/386 -wF cgocall.c
8c -Idarwin -Idarwin/386 -wF chan.c
8c -Idarwin -Idarwin/386 -wF 386/closure.c
8c -Idarwin -Idarwin/386 -wF float.c
8c -Idarwin -Idarwin/386 -wF hashmap.c
8c -Idarwin -Idarwin/386 -wF iface.c
quietgcc -o cgo2c cgo2c.c
./cgo2c malloc.cgo > malloc.c.tmp
mv -f malloc.c.tmp malloc.c
...Two peanuts were walking down the street. One was a salted...
8g -I_obj main.go
8l -L_obj -o ogle main.8
real 0m0.996s
user 0m0.831s
sys 0m0.148s
--- cd ../doc/progs
real 0m2.229s
user 0m1.714s
sys 0m0.431s
--- cd ../test/bench
fasta
reverse-complement
nbody
binary-tree
binary-tree-freelist
fannkuch
regex-dna
spectral-norm
k-nucleotide
mandelbrot
meteor-contest
pidigits
threadring
chameneosredux
--- cd ../test
0 known bugs; 0 unexpected bugs
Trinity:src kelvin$
Okay, so hopefully you now have a working copy of the Go programming language. You can try to find the executables on your system. Your compiler is ’8g’ if for the i386 architecture.
Trinity:~ kelvin$ which 8g
/Users/kelvin/bin/8g
Trinity:~ kelvin$ which 8l
/Users/kelvin/bin/8l
Trinity:~ kelvin$ 8g
flags:
-I DIR search for packages in DIR
-d print declarations
-e no limit on number of errors printed
-f print stack frame structure
-h panic on an error
-k name specify package name
-o file specify output file
-S print the assembly language
-w print the parse tree after typing
-x print lex tokens
Trinity:~ kelvin$
Notice that ‘gccgo’ is not installed by default; if you want to try that out you need to install it separately. Try working through the examples!
分享到:
相关推荐
gogland-173.3188.63.dmg, GOLANG最好用的IDE, 需要的同学下载吧!
Golang client for interacting with Moov API server side
最新的Golang Mac安装版1.11,免去你到处找上网的麻烦
go install golang.org/x/tools/cmd/guru go install github.com/cweill/gotests/... go install github.com/josharian/impl go install github.com/sqs/goreturns go install golang.org/x/lint/golint go ...
在Golang中,`for`循环遍历`channel`是一种常见的操作,用于处理并发和同步。然而,在实际编程中,不正确的使用方式可能导致意料之外的后果,如上述例子所示。这里我们将深入探讨在遍历`channel`时需要注意的问题。 ...
由于golang官网会打不开,下载golang官网包,版本1.11.4
go golang 1.19.2 mac 包
an es hook base golang for log
例如,在Ubuntu上,可以使用`sudo apt-get install golang`命令,而在CentOS或Fedora上,可以使用`sudo yum install golang`或`sudo dnf install golang`。安装后,检查Go版本以确认安装无误。 2. **对接S3对象存储...
weixin-golang-sdk 微信golang工具包
微信小程序服务端SDK(for Golang)是专为Golang开发者设计的一个工具包,用于方便地与微信小程序进行交互和数据通信。这个SDK允许开发者在服务端实现与小程序的无缝对接,提供高效、稳定的服务支持。本文将详细介绍...
本文主要给大家介绍了关于Golang实现字符串倒序的相关内容,分享出来供大家参考学习,下面话不多说了,来一起看看详细的介绍: 字符串倒置如下: Hello World –> dlroW olleH 解决方案1: length := len(str) ...
Go语言,通常被称为Golang,是由Google开发的一种静态类型的、编译式的、并发型且具有垃圾回收功能的编程语言。Go语言的设计目标是提高开发者的生产效率,提供简洁的语法和强大的工具链,同时保持高性能。在本安装包...
Golang Windows 1.19.1版本安装包
本教程将探讨如何使用Golang来实现一个FORTH系统,这是一个非常有趣的编程实践,可以帮助我们理解Golang语言的底层机制以及FORTH的工作原理。 在Golang中实现FORTH,首先我们需要了解FORTH的基本结构。FORTH是一种...
本文实例讲述了golang语言中for循环语句用法。分享给大家供大家参考。具体分析如下: for循环是用来遍历数组或数字的。用for循环遍历字符串时,也有 byte 和 rune 两种方式.第一种为byte,第二种rune. 代码如下:...
for { // 模拟鼠标点击 robotstxt.ClickMouse(100, 100) // 在(100,100)坐标点击 time.Sleep(1 * time.Second) // 等待1秒 } } ``` 在这个示例中,`robotstxt`库被用来模拟鼠标行为,`ClickMouse`函数接收...
在编程领域,Go语言(Golang)以其高效、简洁和并发特性受到了许多开发者的青睐。在Windows平台上,尽管Go语言最初的设计目标并非图形用户界面(GUI)开发,但随着技术的发展,已经出现了一些优秀的框架使得Go语言也...
Golang 1.18.10 Windows安装包。Golang 1.18.10 Windows安装包。Golang 1.18.10 Windows安装包。Golang 1.18.10 Windows安装包。Golang 1.18.10 Windows安装包。Golang 1.18.10 Windows安装包。Golang 1.18.10 ...
golang_http_client