當前位置: 首頁>>代碼示例>>Golang>>正文


Golang UUID.String方法代碼示例

本文整理匯總了Golang中code/google/com/p/go-uuid/uuid.UUID.String方法的典型用法代碼示例。如果您正苦於以下問題:Golang UUID.String方法的具體用法?Golang UUID.String怎麽用?Golang UUID.String使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在code/google/com/p/go-uuid/uuid.UUID的用法示例。


在下文中一共展示了UUID.String方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: LoadSuperblock

func (bs *BlockStore) LoadSuperblock(id uuid.UUID, generation uint64) *Superblock {
	var sb = fake_sblock{}
	if generation == LatestGeneration {
		//log.Info("loading superblock uuid=%v (lgen)", id.String())
		qry := bs.db.C("superblocks").Find(bson.M{"uuid": id.String()})
		if err := qry.Sort("-gen").One(&sb); err != nil {
			if err == mgo.ErrNotFound {
				lg.Info("sb notfound!")
				return nil
			} else {
				lg.Panic(err)
			}
		}
	} else {
		qry := bs.db.C("superblocks").Find(bson.M{"uuid": id.String(), "gen": generation})
		if err := qry.One(&sb); err != nil {
			if err == mgo.ErrNotFound {
				return nil
			} else {
				lg.Panic(err)
			}
		}
	}
	rv := Superblock{
		uuid:     id,
		gen:      sb.Gen,
		root:     sb.Root,
		unlinked: sb.Unlinked,
	}
	return &rv
}
開發者ID:gtfierro,項目名稱:btrdb,代碼行數:31,代碼來源:blockstore.go

示例2: Delete

func (p *MemoryPersistence) Delete(client string, direction dirFlag, uid uuid.UUID) bool {
	//only need to get a read lock on the persistence store, but lock the underlying
	//persistenceentry for the client we're working with.
	p.RLock()
	defer p.RUnlock()
	//checks that there is actually an entry for the message id we're being asked to
	//delete, if there isn't return false, otherwise delete the entry.
	id := uid.String()
	DEBUG.Println("Removing persisted message for", client)
	switch direction {
	case INBOUND:
		p.inbound[client].Lock()
		defer p.inbound[client].Unlock()
		//if there is already an entry for this message id return false
		if _, ok := p.inbound[client].messages[id]; !ok {
			return false
		}
		delete(p.inbound[client].messages, id)
	case OUTBOUND:
		p.outbound[client].Lock()
		defer p.outbound[client].Unlock()
		//if there is already an entry for this message id return false
		if _, ok := p.outbound[client].messages[id]; !ok {
			return false
		}
		delete(p.outbound[client].messages, id)
	}
	return true
}
開發者ID:RouGang,項目名稱:hrotti,代碼行數:29,代碼來源:memory_persistence.go

示例3: GetByUuid

func (db *InMemDatabase) GetByUuid(id uuid.UUID) (contrail.IObject, error) {
	uid := makeUID(id)
	obj, ok := db.objByIdMap[uid]
	if !ok {
		return nil, fmt.Errorf("%s: Not found", id.String())
	}
	return obj, nil
}
開發者ID:netturpin,項目名稱:contrail-go-api,代碼行數:8,代碼來源:database.go

示例4: newPod

func newPod(h *Host, id uuid.UUID) *Pod {
	if id == nil {
		id = uuid.NewRandom()
	}
	return &Pod{
		Host: h,
		UUID: id,
		ui:   ui.NewUI("yellow", "pod", id.String()),
	}
}
開發者ID:dataVerve,項目名稱:jetpack,代碼行數:10,代碼來源:pod.go

示例5: NewImage

func NewImage(h *Host, id uuid.UUID) *Image {
	if id == nil {
		id = uuid.NewRandom()
	}
	return &Image{
		Host:     h,
		UUID:     id,
		Manifest: *schema.BlankImageManifest(),
		ui:       ui.NewUI("blue", "image", id.String()),
	}
}
開發者ID:sdoumbouya,項目名稱:jetpack,代碼行數:11,代碼來源:image.go

示例6: UnlinkGenerations

func (bs *BlockStore) UnlinkGenerations(id uuid.UUID, sgen uint64, egen uint64) error {
	iter := bs.db.C("superblocks").Find(bson.M{"uuid": id.String(), "gen": bson.M{"$gte": sgen, "$lt": egen}, "unlinked": false}).Iter()
	rs := fake_sblock{}
	for iter.Next(&rs) {
		rs.Unlinked = true
		_, err := bs.db.C("superblocks").Upsert(bson.M{"uuid": id.String(), "gen": rs.Gen}, rs)
		if err != nil {
			lg.Panic(err)
		}
	}
	return nil
}
開發者ID:gtfierro,項目名稱:btrdb,代碼行數:12,代碼來源:blockstore.go

示例7: DEBUG_DELETE_UUID

func (bs *BlockStore) DEBUG_DELETE_UUID(id uuid.UUID) {
	lg.Info("DEBUG removing uuid '%v' from database", id.String())
	_, err := bs.db.C("superblocks").RemoveAll(bson.M{"uuid": id.String()})
	if err != nil && err != mgo.ErrNotFound {
		lg.Panic(err)
	}
	if err == mgo.ErrNotFound {
		lg.Info("Quey did not find supeblock to delete")
	} else {
		lg.Info("err was nik")
	}
	//bs.datablockBarrier()
}
開發者ID:gtfierro,項目名稱:btrdb,代碼行數:13,代碼來源:blockstore.go

示例8: ObtainGeneration

/*
 * This obtains a generation, blocking if necessary
 */
func (bs *BlockStore) ObtainGeneration(id uuid.UUID) *Generation {
	//The first thing we do is obtain a write lock on the UUID, as a generation
	//represents a lock
	mk := UUIDToMapKey(id)
	bs.glock.RLock()
	mtx, ok := bs._wlocks[mk]
	bs.glock.RUnlock()
	if !ok {
		//Mutex doesn't exist so is unlocked
		mtx := new(sync.Mutex)
		mtx.Lock()
		bs.glock.Lock()
		bs._wlocks[mk] = mtx
		bs.glock.Unlock()
	} else {
		mtx.Lock()
	}

	gen := &Generation{
		cblocks: make([]*Coreblock, 0, 8192),
		vblocks: make([]*Vectorblock, 0, 8192),
	}
	//We need a generation. Lets see if one is on disk
	qry := bs.db.C("superblocks").Find(bson.M{"uuid": id.String()})
	rs := fake_sblock{}
	qerr := qry.Sort("-gen").One(&rs)
	if qerr == mgo.ErrNotFound {
		lg.Info("no superblock found for %v", id.String())
		//Ok just create a new superblock/generation
		gen.Cur_SB = NewSuperblock(id)
	} else if qerr != nil {
		//Well thats more serious
		lg.Panic("Mongodb error: %v", qerr)
	} else {
		//Ok we have a superblock, pop the gen
		//log.Info("Found a superblock for %v", id.String())
		sb := Superblock{
			uuid: id,
			root: rs.Root,
			gen:  rs.Gen,
		}
		gen.Cur_SB = &sb
	}

	gen.New_SB = gen.Cur_SB.Clone()
	gen.New_SB.gen = gen.Cur_SB.gen + 1
	gen.blockstore = bs
	return gen
}
開發者ID:gtfierro,項目名稱:btrdb,代碼行數:52,代碼來源:blockstore.go

示例9: new_peer

func new_peer(uuid uuid.UUID) (peer *peer_t) {
	peer = &peer_t{
		uuid_bytes:  []byte(uuid),
		uuid_string: uuid.String(),
	}
	return
}
開發者ID:kildevaeld,項目名稱:projects,代碼行數:7,代碼來源:intface.go

示例10: Get

// Get get build data
func (r *LocalFsRegistry) Get(id uuid.UUID) (schema.Build, error) {
	// TODO: add error handling.(Expired Data and Not Found File)
	file, err := os.Open(r.dir + id.String() + ".json")
	if err != nil {
		return schema.Build{}, err
	}
	defer file.Close()

	var build schema.Build

	err = json.NewDecoder(file).Decode(&build)
	if err != nil {
		return schema.Build{}, err
	}

	return build, nil
}
開發者ID:koudaiii,項目名稱:risu,代碼行數:18,代碼來源:local_fs.go

示例11: Get

func (r *EtcdRegistry) Get(id uuid.UUID) (schema.Build, error) {
	key := path.Join(r.keyPrefix, id.String())
	res, err := r.etcd.Get(key, false, true)
	if err != nil {
		return schema.Build{}, err
	}

	var build schema.Build
	err = unmarshal(res.Node.Value, &build)
	if err != nil {
		if isKeyNotFound(err) {
			// TODO (spesnova): return 404 error
			return schema.Build{}, err
		}
		return schema.Build{}, err
	}

	return build, nil
}
開發者ID:koudaiii,項目名稱:risu,代碼行數:19,代碼來源:etcd.go


注:本文中的code/google/com/p/go-uuid/uuid.UUID.String方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。