- 博客(10)
- 收藏
- 关注
原创 nodejs和java中的des/3des加密解密
Java和nodejs中des加解密数据互操作,直接上代码(仅供参考): var assert = require('assert'); var crypto = require('crypto'); function test_des(param) { var key = new Buffer(param.key); var iv = new Buffer(param.i...
2014-02-18 20:54:21
498
原创 go 反射
interface中保存了实际对象的值和类型 func TypeOf(i interface{}) Type func ValueOf(i interface{}) Value Settability is determined by whether the reflection object holds the original item var x float64 =...
2014-01-25 15:50:19
123
原创 go 指针强转
import "unsafe" var a uint = 0 p := uintptr(unsafe.Pointer(&a)) for i := 0; i < int(unsafe.Sizeof(a)); i++ { p += 1 pb := (*byte)(unsafe.Pointer(p)) *pb = 1 } fmt.Printf...
2014-01-24 14:30:30
965
原创 go built-in functions
close() len() cap() new() make() //slice, map, channel append() copy() delete() complex() real() imag() panic() recover() close(ch) //panic when ch is nil or closed channel len(ch)) ...
2014-01-24 14:05:52
153
原创 go range
//array or slic datas := []int{1, 2, 3} //datas := [...]int{1, 2, 3} //datas := &[...]int{1, 2, 3} for idx, v := range datas { fmt.Println(idx, v) } //If only the first itera...
2014-01-24 13:13:10
100
原创 go type switch
var v interface{} = "123" switch t := v.(type) { case nil: fmt.Println("v is nil") case int: fmt.Println("v is int") //fallthrough is not permitted in a type switch default: fmt....
2014-01-24 11:00:39
187
原创 go xml
import ( "encoding/xml" "fmt" ) type Pkg struct { PkgType int `xml:"P"` //P:包类型 } type Message struct { XMLName xml.Name `xml:"DP"` Pkg Name string `xml:"D"` Age int //`xml...
2014-01-17 22:59:42
117
原创 go json
import "encoding/json" type Message struct { Name string Body []string Time int64 tel string //not exported } m := Message{"jack", []string{"hello", "112"}, 1294706395881547000} r, e...
2014-01-17 22:51:31
94
原创 go misc
//有点没点不一样 days1 := [...]string{"Sat", "Sun"} //array [2]string days2 := []string{"Sat", "Sun"} //slice []string //key为位置 vowels := [...]bool{'a': true, 'e': true, 'i': true, 'o': true...
2014-01-17 16:59:21
140
原创 go select
select用于处理多个ch。 其所有case中的channel表达式和右侧的发送语句都会被计算(从上到下) 如果多个case都可以执行,则随机选择一个case。 func test_select_recv() { ch := make(chan int) go func() { fmt.Println("select begin") select { ...
2014-01-17 16:41:56
136
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人