本文整理匯總了Golang中github.com/golang/groupcache.Sink.SetString方法的典型用法代碼示例。如果您正苦於以下問題:Golang Sink.SetString方法的具體用法?Golang Sink.SetString怎麽用?Golang Sink.SetString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/golang/groupcache.Sink
的用法示例。
在下文中一共展示了Sink.SetString方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: layerGetter
func layerGetter(ctx groupcache.Context, key string, dest groupcache.Sink) error {
m, err := fromKey(key)
if err != nil {
return err
}
land, err := m.nePolySVG(m.zoom, 0)
if err != nil {
return err
}
lakes, err := m.nePolySVG(m.zoom, 1)
if err != nil {
return err
}
l, err := m.labels()
if err != nil {
return err
}
var b bytes.Buffer
b.WriteString(fmt.Sprintf("<path fill=\"whitesmoke\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke=\"lightslategrey\" d=\"%s\"/>", land))
b.WriteString(fmt.Sprintf("<path fill=\"azure\" stroke-width=\"1\" stroke=\"lightslategrey\" d=\"%s\"/>", lakes))
b.WriteString(labelsToSVG(l))
return dest.SetString(b.String())
}
示例2: getter
func getter(ctx groupcache.Context, key string, dest groupcache.Sink) error {
resp, _ := http.Get(key)
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
log.Printf("asking for %s from solr\n", key)
dest.SetString(string(body))
return nil
}
示例3: lakeGetter
func lakeGetter(ctx groupcache.Context, key string, dest groupcache.Sink) error {
m, err := fromKey(key)
if err != nil {
return err
}
lakes, err := m.nePolySVG(m.zoom, 1)
if err != nil {
return err
}
return dest.SetString(lakes)
}
示例4: layerGetter
func layerGetter(ctx groupcache.Context, key string, dest groupcache.Sink) error {
m, err := fromKey(key)
if err != nil {
return err
}
land, err := m.nePolySVG(m.zoom, 0)
if err != nil {
return err
}
lakes, err := m.nePolySVG(m.zoom, 1)
if err != nil {
return err
}
stdDev := 4
coast := 10
if m.width > 150 {
stdDev = 10
coast = 30
}
l, err := m.labels()
if err != nil {
return err
}
var b bytes.Buffer
b.WriteString(fmt.Sprintf("<defs><filter id=\"f1\"><feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"%d\" /></filter></defs>", stdDev))
b.WriteString(fmt.Sprintf("<path stroke-width=\"%d\" stroke-linejoin=\"round\" filter=\"url(#f1)\" stroke=\"azure\" d=\"%s\"/>", coast, land))
b.WriteString(fmt.Sprintf("<path fill=\"whitesmoke\" stroke-width=\"1\" stroke-linejoin=\"round\" stroke=\"lightslategrey\" d=\"%s\"/>", land))
b.WriteString(fmt.Sprintf("<path fill=\"azure\" stroke-width=\"1\" stroke=\"lightslategrey\" d=\"%s\"/>", lakes))
b.WriteString(labelsToSVG(l))
return dest.SetString(b.String())
}