我的站点

一个系统软件工程师的随手涂鸦

Date: 三月 31, 2016

2016年3月简讯

这个月比较平淡,基本就是按部就班,也没什么特别的事。

工作方面:
主要是集中在Oracledocker container中的性能测试。这一个月下来,自己在docker方面的知识长进不少。

业余时间:
被生计所迫,被迫暂停了Haskellsysdig的学习,又把Golang重新捡起来了。作为练习,写了一个gouname的小项目。另外,看到stackoverflow上两道有趣的算法题,花了3天时间用Golang解决了,很有成就感。

 

Go语言的struct

以下摘自The Go Programming Language

If all the fields of a struct are comparable, the struct itself is comparable, so two expressions of that type may be compared using == or !=. The == operation compares the corresponding fields of the two structs in order.

 

A named struct type S can’t declare a field of the same type S: an aggregate value cannot contain itself. (An analogous restriction applies to arrays.) But S may declare a field of the pointer type *S, which lets us create recursive data structures like linked lists and trees.

 

The struct type with no fields is called the empty struct, written struct{}. It has size zero and carries no information but may be useful nonetheless. Some Go programmers use it instead of bool as the value type of a map that represents a set, to emphasize that only the keys are significant, but the space saving is marginal and the syntax more cumbersome, so we generally avoid it.

Go lets us declare a field with a type but no name; such fields are called anonymous fields. The type of the field must be a named type or a pointer to a named type.

 

Powered by WordPress & Theme by Anders Norén