Web Analytics

Go中的系统Signal处理

我们在生产环境下运行的系统要求优雅退出,即程序接收退出通知后,会有机会先执行一段清理代码,将收尾工作做完后再真正退出。我们采用系统Signal来 通知系统退出,即kill pragram-pid。我们在程序中针对一些系统信号设置了处理函数,当收到信号后,会执行相关清理程序或通知各个子进程做自清理。kill -9强制杀掉程序是不能被接受的,那样会导致某些处理过程被强制中断,留下无法恢复的现场,导致消息被破坏,影响下次系统启动运行。 ...

September 21, 2012 · 4 min · Tony Bai

Go语言标准库概览

本文翻译自Dr.Dobb’s的"A Brief Tour of the Go Standard Library“一文。 在Go语言五周系列教程的最后一部分中,我们将带领大家一起来浏览一下Go语言丰富的标准库。 Go标准库包含了大量包,提供了丰富广泛的功能特性。这里提供了概览仅仅是有选择性的且非常简单。本文发表后,标准库的内容还可能继续增加,因此 建议大家最好是通过在线查阅库API或使用godoc(包含在Go发布包中)来获取最新信息以及全面了解每个包所具备的功能。 ...

September 8, 2012 · 18 min · Tony Bai

Go程序设计语言(三)

本文译自Rob Pike的Go语言PPT教程 – “The Go Programming Language Part3(updated June 2011)"。由于该教程的最新更新时间早于Go 1版本发布,因此该PPT中的一些内容与Go 1语言规范略有差异,到时我会在相应的地方做上注解。 ...

August 28, 2012 · 11 min · Tony Bai

Go程序设计语言(二)

重写工作方式正如字段一样。 type NamedPoint struct { Point name string } func (n *NamedPoint) Abs() float64 { return n.Point.Abs() * 100. } n := &NamedPoint{Point{3, 4}, “Pythagoras”} fmt.Println(n.Abs()) // prints 500 当然,你可以有多个不同类型的匿名字段 – 一个简单版本的多继承。但冲突解决规则让事情保持简单。 ...

August 27, 2012 · 10 min · Tony Bai

Go程序设计语言(一)

int uint int8 uint8 = byte int16 uint16 int32 uint32 float32 complex64 int64 uint64 float64 complex128 还有uintptr,一个大小足够存储一个指针的数值。 这些都是互不相同的类型;int不等于是int32,即便是在一个32位的机器上。 ...

August 23, 2012 · 13 min · Tony Bai

也谈Go语言编程 – Hello,Go!

Go is expressive, concise, clean, and efficient. Its concurrency mechanisms make it easy to write programs that get the most out of multicore and networked machines, while its novel type system enables flexible and modular program construction. Go compiles quickly to machine code yet has the convenience of garbage collection and the power of run-time reflection. It’s a fast, statically typed, compiled language that feels like a dynamically typed, interpreted language. – 摘自Go语言官方站点 ...

August 17, 2012 · 11 min · Tony Bai