Go语言中文网 为您找到相关结果 9

Go语言的“++”和“—”运算符

以下摘自The Go Programming Language: The increment statement i++ adds 1 to i ; it’s equivalent to i += 1 which is in turn equivalent to i = i + 1 . There’s a corresponding decrement statement i– that subtracts 1. These are statements, not expressions as the y are in most languages in the C family, so j = i++ is illegal, and the y are postfix only, so –...阅读全文

博文 2017-06-24 19:22:04 肖楠

Go语言的const

以下摘自The Go Programming Language: A const declaration gives names to constants, that is, values that are fixed at compile time. The value of a constant must be a number, string, or boolean. const的值只能是数字,字符串或者布尔值。 A constant declaration may specify a type as well as a value, but in the absence of an explicit type, the type is inferred from the expres...阅读全文

博文 2017-06-24 19:31:23 肖楠

golang 使用时间通过md5生成token

package main import ( "crypto/md5" "fmt" "io" "strconv" "time" ) func main() { crutime := time.Now().Unix() fmt.Println("crutime-->", crutime) h := md5.New() fmt.Println("h-->", h) fmt.Println("strconv.FormatInt(crutime, 10)-->", strconv.FormatInt(crutime, 10)) io.WriteString(h, strconv.FormatInt(crutime, 10)) fmt.Println("h-->", h) token := fmt.Sp...阅读全文

博文 2015-06-17 20:03:54 u012210379

修改golang最大内存限制

摘自golang nut You can tune the MHeapMap_Bits in malloc.h and arena_size in malloc.goc to reduce memory usage, as long as they statisfy this: (1UL << (12 + MHeapMap_Bits)) >= arena_size (for example, I changed MHeapMap_Bits to 20, and arena_size to ”4LL<<30“, all tests passed, and the size of bss sections is dropped to about 10MB for bin/go: linux-am...阅读全文

博文 2016-04-22 21:00:01 sorawa

go语言学习-method和function

go语言作为一种面向对象的语言,并没有提供C++中的“成员函数”这一种说法,而是用method(方法)来表示。 1、method和function的关系: method是特殊的function,定义在某一特定的类型上,通过类型的实例来进行调用,这个实例被叫receiver。(a Go method is a function that acts onvariable of a certain type, called the receiver. So a method is a specialkindof function. ---摘自《Go语言程序设计》)。 2、为普通类型添加method: go语言不允许为简单的内置类型添加method,如: func(iint)adder_int(ji...阅读全文

博文 2016-04-22 20:00:04 kuoshuang

Go语言的bit clear操作

以下摘自The Go Programming Language: The &^ operator is bit clear (AND NOT): in the expression z = x &^ y, each bit of z is 0 if the corresponding bit of y is 1; otherwise it equals the corresponding bit of x. 即z = x &^ y运算相当于先把y取反(针对y的每个bit:0变成1,1变成0),然后再和x进行&运算。参考下例: package main import "fmt" func main(){ var x uint8 = 1 var y uint8 = 1 << 2 fmt.Prin...阅读全文

博文 2017-06-24 19:32:57 肖楠

"go back" step in a workflow stops everything

I created a set of approvals in a Purchase Order workflow, I added a rejection step among the workflow steps. The approvals flow smoothly, my problem is that when rejecting one approval and get back to the previous workflow state everything stops and is then unable to change the state by clicking the current approval whenever go back in any workflo...阅读全文

博文 2016-03-22 20:00:00 shanzhizi

Go语言中使用fmt.Printf的小技巧

以下摘自The Go Programming Language: When printing numbers using the fmt package, we can control the radix and format with the %d, %o, and %x verbs, as shown in this example: o := 0666 fmt.Printf(“%d %[1]o %#[1]o\n”, o) // “438 666 0666” x := int64(0xdeadbeef) fmt.Printf(“%d %[1]x %#[1]x %#[1]X\n”, x) // Output: // 3735928559 deadbeef 0xdeadbeef 0XDEAD...阅读全文

博文 2017-06-25 13:53:53 肖楠

Go语言import语句的位置

以下摘自The Go Programming Language: The import declarations must follow the package declaration.After that, a program consists of the declarations of functions, variables, constants, and types (introduced by the key words func, var , const , and type ); for the most part, the order of declarations does not matter. import语句必须跟在package定义后面。请看下例: package...阅读全文

博文 2017-06-24 19:21:57 肖楠