本文整理汇总了Golang中github.com/corestoreio/csfw/config.ScopeIDer.ScopeID方法的典型用法代码示例。如果您正苦于以下问题:Golang ScopeIDer.ScopeID方法的具体用法?Golang ScopeIDer.ScopeID怎么用?Golang ScopeIDer.ScopeID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/corestoreio/csfw/config.ScopeIDer
的用法示例。
在下文中一共展示了ScopeIDer.ScopeID方法的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())
}
示例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
}
示例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())
}