摘要: Go语言的Interface很大不同于C#,Java这种OOP语言的,其强大之处之一在于非侵入式设计。先引用一段基于C++的关于非侵入性的阐述 http://blog.csdn.net/chelsea/article/details/446298基础复杂性是守恒的,需要解决的基本问题始终是需要解决的;最终的复杂性,却取决于基础复杂性彼此间的依赖,如果互相依赖,最终将得到指数级的复杂性,而 如果彼此独立,最终只是若干基础复杂性简单的累加,因此,程序需要更好的的Design和Organize,主要任务就是“降低模块间的依赖至最小”,而 对开发效率有重大影响的,主要是编译期依赖,为此,人们发明了若干 阅读全文
posted @ 2012-11-21 00:59 Gizak 阅读(1426) 评论(0) 推荐(0) 编辑
摘要: A Tour of Go系列。如有问题欢迎指出~这个也没什么好说的,就是试一下内建的复数运算。Let's explore Go's built-in support for complex numbers via thecomplex64andcomplex128types. For cube roots, Newton's method amounts to repeating:Find the cube root of 2, just to make sure the algorithm works. There is aPowfunction in themath 阅读全文
posted @ 2012-10-11 22:27 Gizak 阅读(251) 评论(0) 推荐(0) 编辑
摘要: A Tour of Go系列。如有问题欢迎指出~closure即是俗话说的闭包,闭包三言两语说不清楚,而且本人也不甚了解。简单说就是语法定界,内部的函数可以引用外部上下文的变量,外部的变量会随之捕获并保存。一般来说带闭包的语言函数是可以作为first class的,Go也是如此。这意味这在Go中你可以以类似普通变量一样声明、赋值、传递一个函数变量。练习要求:Implement afibonaccifunction that returns a function (a closure) that returns successive fibonacci numbers.实现一个斐波那契数列函数, 阅读全文
posted @ 2012-10-11 21:43 Gizak 阅读(312) 评论(0) 推荐(0) 编辑
摘要: A Tour of Go系列。如有问题欢迎指出~第三篇,先解释一下要求:ImplementPic. It should return a slice of lengthdy, each element of which is a slice ofdx8-bit unsigned integers. When you run the program, it will display your picture, interpreting the integers as grayscale (well, bluescale) values.The choice of image is up to y 阅读全文
posted @ 2012-10-11 20:22 Gizak 阅读(756) 评论(0) 推荐(1) 编辑
摘要: A Tour of Go系列。如有问题欢迎指出~Tour第二篇,直接贴代码吧,同样很简单。 1 package main 2 3 import ( 4 "code.google.com/p/go-tour/wc" 5 "strings" 6 ) 7 8 func WordCount(s string) map[string]int { 9 cntWord:=make(map[string]int)10 for _,v:=range strings.Fields(s){11 cntWord[v]+=112 }13 return ... 阅读全文
posted @ 2012-10-10 22:04 Gizak 阅读(248) 评论(0) 推荐(0) 编辑
摘要: A Tour of Go系列。如有问题欢迎指出~Tour的第一个练习,非常简单,答案如下: 1 package main 2 3 import ( 4 "fmt" 5 ) 6 7 func Sqrt(x float64) float64 { 8 z:=float64(1) //z须为float64型变量 9 for i:=0;i<10;i++{10 z=z-(z*z-x)/(2*z)11 }12 return z13 }14 15 func main() {16 fmt.Println(Sqrt(2))17 }需要注意的是Go... 阅读全文
posted @ 2012-10-10 21:43 Gizak 阅读(209) 评论(0) 推荐(0) 编辑
摘要: Go 是Google出品的一款性能和开发效率十分出色的系统级编程语言,比较适合编写Server等大型多人程序,被认为是网络时代的C语言。(介绍具体略过。。)A Tour of Go 就是Google出品并部署在Google服务器上用Go编写的一个Web Server的Go语言学习指南,里面的内容很精简,如果你有编程经验的话将会上手很快。因为大陆访问Google总会有些问题,原因大家都懂的,所以推荐将A Tour of Go安装在本地。废话不多说了,来看具体实施:安装Go:官方网站为golang.­org。安装Mercurial:如果你之前没有安装过Mercurial,请安装Mercu 阅读全文
posted @ 2012-10-10 20:53 Gizak 阅读(951) 评论(0) 推荐(0) 编辑
摘要: 开篇必须是这个!!想了好久Hello有没有拼错= =。 阅读全文
posted @ 2012-10-08 21:56 Gizak 阅读(121) 评论(0) 推荐(0) 编辑