本文整理汇总了Golang中github.com/attic-labs/noms/ref.Ref.String方法的典型用法代码示例。如果您正苦于以下问题:Golang Ref.String方法的具体用法?Golang Ref.String怎么用?Golang Ref.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/attic-labs/noms/ref.Ref
的用法示例。
在下文中一共展示了Ref.String方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: updateRootByKey
func (l *internalLevelDBStore) updateRootByKey(key []byte, current, last ref.Ref) bool {
l.mu.Lock()
defer l.mu.Unlock()
if last != l.rootByKey(key) {
return false
}
// Sync: true write option should fsync memtable data to disk
err := l.db.Put(key, []byte(current.String()), &opt.WriteOptions{Sync: true})
d.Chk.NoError(err)
return true
}
示例2: requestRef
func (h *HTTPStore) requestRef(r ref.Ref, method string, body io.Reader) *http.Response {
url := *h.host
url.Path = httprouter.CleanPath(h.host.Path + constants.RefPath)
if !r.IsEmpty() {
url.Path = path.Join(url.Path, r.String())
}
header := http.Header{}
if body != nil {
header.Set("Content-Type", "application/octet-stream")
}
req := h.newRequest(method, url.String(), body, header)
res, err := h.httpClient.Do(req)
d.Chk.NoError(err)
return res
}
示例3: requestRoot
func (h *HTTPStore) requestRoot(method string, current, last ref.Ref) *http.Response {
u := *h.host
u.Path = httprouter.CleanPath(h.host.Path + constants.RootPath)
if method == "POST" {
d.Exp.False(current.IsEmpty())
params := url.Values{}
params.Add("last", last.String())
params.Add("current", current.String())
u.RawQuery = params.Encode()
}
req := h.newRequest(method, u.String(), nil, nil)
res, err := h.httpClient.Do(req)
d.Chk.NoError(err)
return res
}
示例4: assertInputInStore
func assertInputInStore(input string, ref ref.Ref, s ChunkStore, assert *assert.Assertions) {
chunk := s.Get(ref)
assert.False(chunk.IsEmpty(), "Shouldn't get empty chunk for %s", ref.String())
assert.Equal(input, string(chunk.Data()))
}
示例5: assertInputNotInStore
func assertInputNotInStore(input string, ref ref.Ref, s ChunkStore, assert *assert.Assertions) {
data := s.Get(ref)
assert.Nil(data, "Shouldn't have gotten data for %s", ref.String())
}
示例6: writeRef
func (w *jsonArrayWriter) writeRef(r ref.Ref) {
w.write(r.String())
}
示例7: ToTag
// ToTag replaces "-" characters in s with "_", so it can be used in a Go identifier.
// TODO: replace other illegal chars as well?
func ToTag(r ref.Ref) string {
return strings.Replace(r.String()[0:12], "-", "_", -1)
}
示例8: RefToJSIdentfierName
// RefToJSIdentfierName generates an identifier name representing a Ref. ie. `sha1_abc1234`.
func (gen *Generator) RefToJSIdentfierName(r ref.Ref) string {
return strings.Replace(r.String(), "-", "_", 1)[0:12]
}