Go语言中文网 为您找到相关结果 4

Go安装的设置问题:GOROOT,GOPATH

Mac下使用Google官方的Go语言安装包:https://code.google.com/p/go/downloads/list 安装的Go,会自动把 /usr/local/go/bin 目录加入PATH中。这样我们直接在控制台就可以执行go语言的一些命令。 http://golang.org/cmd/go/#hdr-GOPATH_environment_variable http://www.cnblogs.com/ghj1976/archive/2013/01/16/2863142.html Go的二进制编译包假设你把Go安装在 /usr/local/go (或者Window是 c:\Go)目录下。当然你也可以安装在其他目录下,不过这时候你就需要设置GOROOT环...阅读全文

golang--监控goroutine异常退出

在golang中,我们可以很轻易产生数以万计的goroutine,不过这也带来了麻烦:在运行中某一个goroutine异常退出,怎么办? 在erlang中,有link原语,2个进程可以链接在一起,一个在异常退出的时候,向另一个进程呼喊崩溃的原因,然后由另一个进程处理这些信号,包括是否重启这个进程。在这方面,erlang的确做得很好,估计以后这个特性会在golang中得到实现。 由此得到启发,我写了一个简单的程序,监控goroutine异常退出。 package main import ( "log" "runtime" "math/rand" "time" ) type message struct { normal bool //true means exit normal, otherw...阅读全文

博文 2014-10-04 19:26:02 getong

go语言实现继承功能

go语言结构体有一个特殊的用法:结构体内嵌一个其他类型的结构体指针,就可以使用内嵌结构体的方法。看代码(摘自studygolang的源码,数据库模块,dao.go) type Dao struct { *sql.DB // 构造sql语句相关 tablename string where string whereVal []interface{} // where条件对应中字段对应的值 limit string order string // 插入需要 columns []string // 需要插入数据的字段...阅读全文

go语言环境

操作系统:ubuntu 64bit 依次执行(这里是在/目录下执行的) 1、sudo apt-get install bison ed gawk gcc libc6-dev make 2、apt-get install python-setuptools python-dev build-essential 3、sudo easy_install mercurial 4、hg clone -r release https://go.googlecode.com/hg/ go 5、cd go/src 6、 ./all.bash 显示: --- cd ../test N known bugs; 0 unexpected bugs --- Installed Go for linux/amd64 ...阅读全文

博文 2014-10-04 19:26:03 canofy