Time of Update: 2014-10-04
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。 今天項目中要將map存入cookie,於是大象哥研究了下json和base64,寫了個小例子 一、將map存入cookie //要存入cookie的mapyour := map[string]string{}your["isuser"] = isuseryour["username"] = usernameyour["password"] =
Time of Update: 2014-10-04
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。 s := strings.Split("", "") fmt.Println(s, len(s)) s = strings.Split("abc,abc", "") fmt.Println(s, len(s)) s = strings.Split("", ",") fmt.Println(s,
Time of Update: 2014-10-04
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。1、當range作用於string時, 第一個傳回值為index,第二次是char str := "hello world" for index, ch := range str { fmt.Printf("%d --- %c\n", index, ch) } 2、當range作用於array時, 第一個傳回值為index,第二次是value func PrintArray(
Time of Update: 2014-10-04
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。package main import "fmt"type Base struct {Name string}func (b *Base) SetName(name string) {b.Name = name}func (b *Base) GetName() string {return b.Name}// 組合,實現繼承type Child struct {base Base // 這裡儲存的是Base類型}
Time of Update: 2014-10-04
這是一個建立於
Time of Update: 2014-10-04
這是一個建立於
Time of Update: 2014-10-04
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。package main import "fmt"type IReader interface {Read(file string) []byte}type IWriter interface {Write(file string, data []byte)}// 介面組合, 這些預設就繼承了Reader和Writer中的抽象方法type IReadWriter interface {IReaderIWriter}
Time of Update: 2014-10-04
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。 把Go程式變小的辦法是: go build -ldflags "-s -w" (go install類似) -s去掉符號表(然後panic時候的stack trace就沒有任何檔案名稱/行號資訊了, 這個等價於普通C/C++程式被strip的效果),
Time of Update: 2014-10-04
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。 今天偵錯工具的時候發現程式報is an unexported field of struct type controllers,但是用fmt.Println列印結構能正常 ,只是放到模板引擎中就不能訪問了。 尋找錯誤過程: 在控制台能夠通過FMT包列印結構體,那麼證明文法上應該沒有什麼問題。而且發生錯誤只是在模板調用的時候發生,於是從調用的資料入手。原先的定義的結構是 type
Time of Update: 2014-10-04
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。 代碼如下 now := time.Now()year, mon, day := now.UTC().Date()hour, min, sec := now.UTC().Clock()zone, _ := now.UTC().Zone()fmt.Printf("UTC 時間是 %d-%d-%d %02d:%02d:%02d %s\n",year, mon, day, hour, min, sec,
Time of Update: 2014-10-04
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。http://www.linuxidc.com/Linux/2014-06/103843.htm package mainimport ( "encoding/base64" "fmt")const ( base64Table = "1230QRSTUabcdVWXYZHijKLAWDCABDstEFGuvwxyzGHIJklmnopqr2345601789120"
Time of Update: 2014-10-04
這是一個建立於
Time of Update: 2014-10-04
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。 Introduction The Go memory model specifies the conditions under which reads of a variable in one goroutine can be guaranteed to observe values produced by writes to the same variable in a different goroutine.
Time of Update: 2014-10-04
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。s2 := append(s1, *)
Time of Update: 2014-10-04
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。使用案例代碼: package mainimport ( "bytes" "fmt" "log" "os/exec")func main() { cmd := exec.Command("php", "D:/baiduyun/command/application/cli", "read")
Time of Update: 2014-10-04
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。 struct轉map package mainimport ("fmt""reflect""time")type User struct {Id int64Username stringPassword stringLogintime time.Time}func Struct2Map(obj interface{})
Time of Update: 2014-10-04
這是一個建立於
Time of Update: 2014-10-04
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。源碼地址 什麼是dnsmasq(摘自網路) Dnsmasq 提供 DNS 緩衝和 DHCP 服務功能。作為網域名稱解析伺服器(DNS),dnsmasq可以通過緩衝 DNS 請求來提高對訪問過的網址的連線速度。作為DHCP 伺服器,dnsmasq 可以為區域網路電腦提供內網ip地址和路由。DNS和DHCP兩個功能可以同時或分別單獨實現。dnsmasq輕量且易配置,適用於個人使用者或少於50台主機的網路。此外它還內建了一個 PXE
Time of Update: 2014-10-04
這是一個建立於
Time of Update: 2014-10-04
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。如果你用的時windows , 請自覺忽略, linux && mac 通用。Sublime Text 有個 gosublime ,用來提供golang的文法解析以及提示什麼的。說實話,我一直想要一個匹配自己開發環境的編譯器, 不用來回切換到命令列去build