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


Golang config.ScopeIDer類代碼示例

本文整理匯總了Golang中github.com/corestoreio/csfw/config.ScopeIDer的典型用法代碼示例。如果您正苦於以下問題:Golang ScopeIDer類的具體用法?Golang ScopeIDer怎麽用?Golang ScopeIDer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: store

// store returns a TableStore by an id or code.
// The non-empty code has precedence if available.
func (st *Storage) store(r config.ScopeIDer) (*TableStore, error) {
	if r == nil {
		return nil, ErrStoreNotFound
	}
	if c, ok := r.(config.ScopeCoder); ok && c.ScopeCode() != "" {
		return st.stores.FindByCode(c.ScopeCode())
	}
	return st.stores.FindByID(r.ScopeID())
}
開發者ID:bom-d-van,項目名稱:csfw,代碼行數:11,代碼來源:storage.go

示例2: hash

// hash generates the key for the map from either an id int64 or a code string.
// If both interfaces are nil it returns 0 which is default for website, group or store.
// fnv64a used to calculate the uint64 value of a string, especially website code and store code.
func hash(r config.ScopeIDer) (uint64, error) {
	uz := uint64(0)
	if r == nil {
		return uz, ErrHashRetrieverNil
	}

	if c, ok := r.(config.ScopeCoder); ok && c.ScopeCode() != "" {
		data := []byte(c.ScopeCode())
		var hash uint64 = 14695981039346656037
		for _, c := range data {
			hash ^= uint64(c)
			hash *= 1099511628211
		}
		return hash, nil
	}
	return uint64(r.ScopeID()), nil
}
開發者ID:bom-d-van,項目名稱:csfw,代碼行數:20,代碼來源:manager.go

示例3: group

// group returns a TableGroup by using a group id as argument. If no argument or more than
// one has been supplied it returns an error.
func (st *Storage) group(r config.ScopeIDer) (*TableGroup, error) {
	if r == nil {
		return nil, ErrGroupNotFound
	}
	return st.groups.FindByID(r.ScopeID())
}
開發者ID:bom-d-van,項目名稱:csfw,代碼行數:8,代碼來源:storage.go


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