加载中
golang 反射

package main import (   "fmt"   "reflect" ) type Person struct{} func (p *Person) Run() {   fmt.Println("person running") } func doit(object interface{}, method in...

2013/06/30 00:39
1K
【转】GO Check if file exists

finfo, err := os.Stat("filename.txt") if err != nil { // no such file or dir return } if finfo.IsDir() { // it's a file } else { // it's a directory }...

2013/06/13 15:55
265
[转]GO RAND

package main import ( "fmt" "time" "math/rand" ) func main() { r := rand.New(rand.NewSource(time.Now().UnixNano())) for i:=0; i<20;...

2013/05/14 11:40
148
[转]GO LIST

package main import (   "container/list"   "fmt" ) func main() {   // 生成队列   l := list.New()   // 入队, 压栈   l.PushBack(1)   l.PushBack(2)   l.PushBack(3)   l.Pu...

2013/05/14 11:26
248
[转]beego cache

package beego import (   "errors"   "fmt"   "strconv"   "sync"   "time" ) var (   DefaultEvery int = 60 // 1 minute ) type BeeItem struct {   val interface{} ...

2013/05/13 11:08
1K
[转]beego safe map

package beego import (   "sync" ) type BeeMap struct {   lock *sync.RWMutex   bm map[interface{}]interface{} } func NewBeeMap() *BeeMap {   return &BeeMap{     lock:...

2013/05/13 11:06
678
[转]beego log

package beego import (   "log"   "os" ) //-------------------- // LOG LEVEL //-------------------- // Log levels to control the logging output. const (   LevelTrace...

2013/05/13 11:04
429
[转]GO LOG FILE

package main import (   "fmt"   "log"   "os" ) func main(){   logfile,err := os.OpenFile("d:/test.log",os.O_RDWR|os.O_CREATE,0);   if err!=nil {     fmt.Printf("%s\r\n",er...

2013/05/13 11:00
174
[转]GO UUID

Here is a simple UUID generator, it uses version 4, Pseudo Random, as described in RFC 4122 uuid.go package uuid import ( "encoding/hex" "crypto/rand" ) func GenUUID(...

2013/05/13 10:55
661

没有更多内容

加载失败,请刷新页面

没有更多内容

返回顶部
顶部