安装golang程序语言
Google的程序设计语言The Go Programming Language发布的时候安装了一下,当时官方安装说明文档不是很清晰,安装过程中还Google很多资料才得以成功,遂记录之。
1.在加入环境变量(最初的文档这里说得最含糊了)
在~/.bashrc加入如下环境变量
export GOROOT=$HOME/go
export GOOS=linux
export GOARCH=386
export GOBIN=$HOME/bin
export PATH=$GOBIN:$PATH
注意:$GOARCH为目标的版本,有amd64/386/arm可供选择。
2.安装Mercurial以获得仓库代码(如果没有hg的话,有则跳过这步)
$ sudo apt-get install python-setuptools python-dev
$ sudo easy_install mercurial
3.从仓库中获得代码
$ hg clone -r release https://go.googlecode.com/hg/ $GOROOT
4.建立GOBIN文件夹
$ mkdir $GOBIN
5.进入资料夹src目录,执行编译
$ cd $GOROOT/src
$ ./all.bash
稍等两三分钟后,看到下面的信息就表示安装成功了。
0 known bugs; 0 unexpected bugs
部分地区可能由于网络的缘故会出现某些网址访问不到的情况,但不一定会导致安装失败,试试编译命令能不能用,例如编译下面的Hello, world!程序。
6.写例子程序测试编译命令
|
1 2 3 4 5 6 7 |
package main import "fmt" func main() { fmt.Printf("Hello, world!\n") } |
保存为hello.go后编译执行
$ 8g hello.go
$ 8l hello.8
$ ./8.out
看到有Hello, world!输出那就正常了。出错就继续折腾吧。Have fun!
Android 1.6 SDK

谷歌这个坏蛋,取消了SDK完整包的下载,还做了强制转向。不过还好,已经有人打包出来供下载了,在此感谢。
linux:
http://kugou.me/android-sdk-linux_x86-1.6_r1.tgz
在main()函数之前调用Bootstrap函数
在所有可执行程序中,调用的第一个函数通常都是其入口main(),但可以使用一些技巧来修改这种行为。全局对象(即具有文件作用域的对象)能满足这种要求,因为全局对象将在程序的main()函数被调用之前创建。程序员可以创建一个类,其默认构造函数将调用所有的bootstrap函数。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
//bootstrap #include <iostream> using namespace std; class Bootstrap{ public: Bootstrap(){ cout<<"Bootstrap.\n"; } ~Bootstrap(){ cout<<"~destory.\n"; } }; Bootstrap req; int main(){ cout<<"hello world!\n"; return 0; } |
Python 风格指南
一个典型模块的内部结构:
- 起始行
- 模块文档(文档字符串)
- 模块导入
- (全局)变量定义
- 类定义(若有)
- 函数定义(若有)
- 主程序
样例代码:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#!/usr/bin/env python #coding:utf-8 "this is a test module" import sys import os debug = True class FooClass(object): "Foo class" pass def test(): "test function" foo = FooClass() if debug: print 'ram test()' if __name__ == '__main__': test() |
