天天看点

Go小tipgo一些“隐藏库”如何为go添加补丁Cmd的三个运行:string如果里面有"的话,可以使用`来进行包含Error接口的陷阱

code.google.com上有一些分支

有的是还没合并到default上的函数功能

比如net/websocket

<a href="http://code.google.com/p/go/source/browse?repo=net#hg%2fwebsocket">http://code.google.com/p/go/source/browse?repo=net#hg%2fwebsocket</a>

这些库可用性都很高,很适合直接使用

http://golang.org/doc/contribute.html

func(*cmd)start

func(*cmd)run

func(*cmd)wait

start:运行不等待进程结束

run:运行等待进程结束

wait:等待进程结束

就是说run = start + wait

process:一旦start开始了,process就可以使用了

processstate:只有进程结束之后才可以使用这个属性。即必须run或者start+wait才能使用。

比如:

jsonstring := ` 

     { 

    "development":{ 

        "connector":[ 

             {"id":"connector-server-1", "host":"127.0.0.1", "port":4050, "wsport":3050}, 

             {"id":"connector-server-2", "host":"127.0.0.1", "port":4051, "wsport":3051}, 

             {"id":"connector-server-3", "host":"127.0.0.1", "port":4052, "wsport":3052} 

         ], 

        "gate":[ 

          {"id": "gate-server-1", "host": "127.0.0.1", "wsport": 3014} 

     ] 

    } 

}`

<a href="http://golang.org/doc/faq#nil_error">http://golang.org/doc/faq#nil_error</a>

自己定义的error接口需要注意,接口是有两个属性的,type和value,当type和value都为nil的时候才会==nil,如果继承自nil的接口,即使val是nil,但是type却是nil类型。

比如这个帖子就是问的这个问题:

<a href="https://groups.google.com/forum/?fromgroups=#!topic/golang-nuts/59gxbvgxcxk">https://groups.google.com/forum/?fromgroups=#!topic/golang-nuts/59gxbvgxcxk</a>