上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 15 下一页
摘要: http://godoc.golangtc.com/doc/faq#inc_dec 简单地说, 在golang中++,--操作是语句而不是表达式. 所以a=b++, return x++之类绝对提示错误. 语句是无法放到表达式的位置 Without pointer arithmetic, the c 阅读全文
posted @ 2016-09-07 13:27 zolo® 阅读(2466) 评论(0) 推荐(0) 编辑
摘要: // Copyright 2009 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE 阅读全文
posted @ 2016-09-07 13:26 zolo® 阅读(801) 评论(0) 推荐(0) 编辑
摘要: 要彻底理解new()与make()的区别, 最好从内存模型入手. golang属于c family, 而c程序在unix的内在模型: |低地址|text|data|bss|heap-->|unused|<--stack|env|高地址| 其中: (1)text存储程序主体,即机器指令. (2)dat 阅读全文
posted @ 2016-09-07 13:26 zolo® 阅读(277) 评论(0) 推荐(0) 编辑
摘要: 在golang中package是个困惑的概念, 特别是package还可以与folder不同名, 委实让我恶心了一把. 关于golang的package的最佳实践: package is folder. package name is folder name. package path is fol 阅读全文
posted @ 2016-09-07 13:25 zolo® 阅读(1328) 评论(0) 推荐(0) 编辑
摘要: slice陷阱,slice底层指向某个array,在赋值后容易导致array长期被引用而无法释放 阅读全文
posted @ 2016-09-07 13:25 zolo® 阅读(194) 评论(0) 推荐(0) 编辑
摘要: 之前说到Golang中某些类型可以赋值nil, 某些类型不能赋值nil. 不能赋值nil都是initialized value不为nil的类型, 例如: bool int, intN uint, uintN floatN complexN byte, rune string struct 可以赋值n 阅读全文
posted @ 2016-09-07 13:23 zolo® 阅读(549) 评论(0) 推荐(0) 编辑
摘要: Golang的并发涉及二个概念: goroutine channel goroutine由关键字go创建. channel由关键字chan定义 channel的理解稍难点, 最简单地, 你把它当成Unix中的双向通道Pipe. 1. channel的定义 2. select阻塞 3. 缓存机制: 使 阅读全文
posted @ 2016-09-07 13:23 zolo® 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 在golang中, 函数是第一类值(first-class object), 即函数可以赋值与被赋值. 换言之, 函数也可以作为ReceiverType, 定义自己的method. 实例: http.HandleFunc(pattern string, handler func(ResponseWr 阅读全文
posted @ 2016-09-07 13:22 zolo® 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 用Golang与perl脚本比较, 初想至多差一倍吧...结果可不是一般的坑爹, 简直就是坑爷了. Perl脚本 #!/bin/bash source /etc/profile; function extractAndZip(){ _debug "$FUNCNAME,$@"; local logFi 阅读全文
posted @ 2016-09-07 13:21 zolo® 阅读(338) 评论(0) 推荐(0) 编辑
摘要: golang写backend之类的应用,还是挺方便的...使用encoding/json包时, 必须注意, 在struct定义的属性必须是exported, 否则不会设置值. 例如:type DRole struct { Id string `json:"id"`}type DataRole str 阅读全文
posted @ 2016-09-07 13:20 zolo® 阅读(199) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 15 下一页