本文整理汇总了Golang中github.com/jeffail/gabs.Container.SetP方法的典型用法代码示例。如果您正苦于以下问题:Golang Container.SetP方法的具体用法?Golang Container.SetP怎么用?Golang Container.SetP使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jeffail/gabs.Container
的用法示例。
在下文中一共展示了Container.SetP方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: appendOpenID
func appendOpenID(t *testing.T, stmt *gabs.Container) *gabs.Container {
stmt, err := gabs.ParseJSON([]byte(stmt.String()))
fatalIfError(t, err)
domainPrefix := uuid.NewV4().String()
openID := "http://" + domainPrefix + ".openid.example.com/"
_, err = stmt.SetP(openID, "actor.openid")
fatalIfError(t, err)
return stmt
}
示例2: appendMbox
func appendMbox(t *testing.T, stmt *gabs.Container) *gabs.Container {
stmt, err := gabs.ParseJSON([]byte(stmt.String()))
fatalIfError(t, err)
domainPrefix := uuid.NewV4().String()
mbox := "mbox:[email protected]" + domainPrefix + ".example.com"
_, err = stmt.SetP(mbox, "actor.mbox")
fatalIfError(t, err)
return stmt
}
示例3: appendMboxSHA1
func appendMboxSHA1(t *testing.T, stmt *gabs.Container) *gabs.Container {
stmt, err := gabs.ParseJSON([]byte(stmt.String()))
fatalIfError(t, err)
data := make([]byte, 16)
_, err = rand.Read(data)
fatalIfError(t, err)
mboxSHA1 := fmt.Sprintf("%x", sha1.Sum(data))
_, err = stmt.SetP(mboxSHA1, "actor.mbox_sha1sum")
fatalIfError(t, err)
return stmt
}
示例4: appendAccount
func appendAccount(t *testing.T, stmt *gabs.Container) *gabs.Container {
stmt, err := gabs.ParseJSON([]byte(stmt.String()))
fatalIfError(t, err)
suffix := uuid.NewV4().String()
name := "name-example-" + suffix
homePage := "http://example.com"
_, err = stmt.SetP(name, "actor.account.name")
fatalIfError(t, err)
_, err = stmt.SetP(homePage, "actor.account.homePage")
fatalIfError(t, err)
return stmt
}
示例5: mergeNetConfig
// Merge ("generate?") guest network configuration from host configuration.
func mergeNetConfig(netconfig *netConfig, guest *gabs.Container) (err error) {
if guest.ExistsP("hostname") {
log.Print("Guest already defines hostname, not overriden")
} else {
guest.SetP(netconfig.hostname, "hostname")
}
if guest.ExistsP("net") {
return fmt.Errorf("Guest already defines net configuration")
}
addrs, _ := guest.ArrayOfSizeP(1, "net.interfaces.vioif0.addrs")
addr, _ := addrs.ObjectI(0)
addr.Set("inet", "type")
addr.Set("static", "method")
addr.Set(netconfig.ipAddress, "addr")
gateways, _ := guest.ArrayOfSizeP(1, "net.gateways")
gw, _ := gateways.ObjectI(0)
gw.Set("inet", "type")
gw.Set(netconfig.gateway, "addr")
dns, _ := guest.ObjectP("net.dns")
dns.Set(netconfig.dnsServers, "nameservers")
dns.Set(netconfig.dnsSearch, "search")
return
}
示例6: cleanToken
func cleanToken(token *gabs.Container) {
token.SetP(html.EscapeString(token.Path("nick").Data().(string)), "nick")
token.SetP(html.EscapeString(token.Path("uid").Data().(string)), "uid")
token.SetP(html.EscapeString(token.Path("name").Data().(string)), "name")
token.SetP(html.EscapeString(token.Path("email").Data().(string)), "email")
token.SetP(html.EscapeString(token.Path("phone").Data().(string)), "phone")
token.SetP(html.EscapeString(token.Path("url").Data().(string)), "url")
token.SetP(html.EscapeString(token.Path("desc").Data().(string)), "desc")
token.SetP(html.EscapeString(token.Path("avatar").Data().(string)), "avatar")
}