天天看點

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>