Elton's Blog

Tag: OSX

在Mac OSX下安装和使用GO语言

by on 八.13, 2010, under Agile Web Development, Mac

Go语言是Google新推出的结合了动态语言和静态语言优势的一个新兴的语言。下面介绍一下如何在Mac系统下安装和使用这个语言。

设置环境变量

$GOROOT
GO语言的根目录,通常是$HOME/go,当然也可以是任何其他目录。

$GOOS 和 $GOARCH
标明GO语言所在的系统和处理器类型。$GOOS可以是linux, freebsd, darwin (Mac OS X 10.5 or 10.6)和 nacl (Native Client, an incomplete port)。$GOARCH可以是amd64 (64-bit x86, the most mature port), 386 (32-bit x86), arm (32-bit ARM, an incomplete port)。

你可以在你的shell profile中设置这些变量,我是放在了~/.bash_profile里了。

1
2
3
4
export GOROOT=$HOME/go
export GOARCH=amd64
export GOOS=darwin
export PATH=$PATH:$GOROOT/bin

其中, $GOROOT/bin是GO默认的可执行文件的目录,加入到path中方便使用go的各种命令。

再执行

1
source ~/.bash_profile

使最新的配置文件生效。

获得源文件

如果你的系统中没有安装Mercurial(没有安装它,你就无法使用hg命令),那么使用这个命令来安装它:

1
$ sudo easy_install mercurial

然后使用下面的命令,还获得GO语言的源文件

1
$ hg clone -r release https://go.googlecode.com/hg/ $GOROOT

安装GO语言

1
2
$ cd $GOROOT/src
$ ./all.bash

如果一切正常,你应该可以在最后看到类似的结果:

1
2
--- cd ../test
N known bugs; 0 unexpected bugs

撰写第一个Hello,World

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ cat >hello.go <<EOF
package main
 
import "fmt"
 
func main() {
	fmt.Printf("hello, worldn")
}
EOF
 
$ 6g hello.go
$ 6l hello.6
$ ./6.out
hello, world
$

日后更新

Go是一个发展中的语言,它的版本会经常进行更新,可以使用以下命令,保持GO语言是最新版本的

1
2
3
4
$ cd $GOROOT/src
$ hg pull
$ hg update release
$ ./all.bash

Go的官方网站是:http://golang.org

15 Comments :, , , more...

Mac OS X:如何校验SHA-1

by on 九.28, 2009, under Mac

从网上下载的软件,有时候为了确保文件的一致性,需要对软件进行sha验证,尤其是apple的一些重要升级文件。

使用一下步骤可以进行校验

1. 打开 Terminal.
2. 输入以下命令:

1
$ /usr/bin/openssl sha1 [full path to file]

例如:

1
2
$ /usr/bin/openssl sha1 /Users/test/Documents/1024SecUpd2003-03-03.dmg
SHA1(/Users/test/Documents/1024SecUpd2003-03-03.dmg) =2eb722f340d4e57aa79bb5422b94d556888cbf38
Leave a Comment :, , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit my friends!

A few highly recommended friends...