本文整理匯總了Golang中github.com/MG-RAST/Shock/shock-client/lib.Node.Update方法的典型用法代碼示例。如果您正苦於以下問題:Golang Node.Update方法的具體用法?Golang Node.Update怎麽用?Golang Node.Update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/MG-RAST/Shock/shock-client/lib.Node
的用法示例。
在下文中一共展示了Node.Update方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
if len(os.Args) == 1 || os.Args[1] == "help" {
helpf("")
}
cmd := os.Args[1]
args := conf.Initialize(os.Args[2:])
setToken(false)
switch cmd {
case "create", "update":
n := lib.Node{}
if cmd == "update" {
if len(args) != 1 {
helpf("update requires <id>")
} else {
n.Id = args[0]
}
}
opts := lib.Opts{}
if ne(conf.Flags["attributes"]) {
opts["attributes"] = (*conf.Flags["attributes"])
}
if t, err := fileOptions(conf.Flags); err != nil {
helpf(err.Error())
} else {
if t == "part" {
if cmd == "create" {
helpf("part option only usable with update")
}
if !ne(conf.Flags["file"]) {
helpf("part option requires file")
}
opts["upload_type"] = t
opts["part"] = (*conf.Flags["part"])
opts["file"] = (*conf.Flags["file"])
if err := n.Update(opts); err != nil {
handleString(fmt.Sprintf("Error updating %s: %s\n", n.Id, err.Error()))
} else {
n.PP()
}
} else {
if t != "" {
opts["upload_type"] = t
opts[t] = (*conf.Flags[t])
if cmd == "create" {
if err := n.Create(opts); err != nil {
handleString(fmt.Sprintf("Error creating node: %s\n", err.Error()))
} else {
n.PP()
}
} else {
if err := n.Update(opts); err != nil {
handleString(fmt.Sprintf("Error updating %s: %s\n", n.Id, err.Error()))
} else {
n.PP()
}
}
} else {
if err := n.Create(opts); err != nil {
handleString(fmt.Sprintf("Error creating node: %s\n", err.Error()))
} else {
n.PP()
}
}
}
}
case "pcreate":
pcreate(args)
case "get":
if len(args) != 1 {
helpf("get requires <id>")
}
n := lib.Node{Id: args[0]}
if err := n.Get(); err != nil {
fmt.Printf("Error retrieving %s: %s\n", n.Id, err.Error())
} else {
n.PP()
}
case "download":
if len(args) < 1 {
helpf("download requires <id>")
}
index := conf.Flags["index"]
parts := conf.Flags["parts"]
indexOptions := conf.Flags["index_options"]
opts := lib.Opts{}
if ne(index) || ne(parts) || ne(indexOptions) {
if ne(index) && ne(parts) {
opts["index"] = (*index)
opts["parts"] = (*parts)
if ne(indexOptions) {
opts["index_options"] = (*indexOptions)
}
} else {
helpf("index and parts options must be used together")
}
}
n := lib.Node{Id: args[0]}
//.........這裏部分代碼省略.........
示例2: main
func main() {
args := flag.Args()
if *conf.Examples {
helpf("Coming soon.")
}
if len(args) == 0 {
helpf("")
}
switch args[0] {
case "create", "update":
n := lib.Node{}
if args[0] == "update" {
if len(args) != 2 {
helpf("update requires <id>")
} else {
n.Id = args[1]
}
}
opts := lib.Opts{}
if ne(conf.Flags["attributes"]) {
opts["attributes"] = (*conf.Flags["attributes"])
}
if t, err := fileOptions(conf.Flags); err != nil {
helpf(err.Error())
} else {
if t == "part" {
if args[0] == "create" {
helpf("part option only usable with update")
}
if !ne(conf.Flags["file"]) {
helpf("part option requires file")
}
opts["upload_type"] = t
opts["part"] = (*conf.Flags["part"])
opts["file"] = (*conf.Flags["file"])
if err := n.Update(opts); err != nil {
fmt.Printf("Error updating %s: %s\n", n.Id, err.Error())
} else {
n.PP()
}
} else {
if t != "" {
opts["upload_type"] = t
opts[t] = (*conf.Flags[t])
if args[0] == "create" {
if err := n.Create(opts); err != nil {
fmt.Printf("Error creating node: %s\n", err.Error())
} else {
n.PP()
}
} else {
if err := n.Update(opts); err != nil {
fmt.Printf("Error updating %s: %s\n", n.Id, err.Error())
} else {
n.PP()
}
}
} else {
if err := n.Create(opts); err != nil {
fmt.Printf("Error creating node: %s\n", err.Error())
} else {
n.PP()
}
}
}
}
case "get":
if len(args) != 2 {
helpf("get requires <id>")
}
n := lib.Node{Id: args[1]}
if err := n.Get(); err != nil {
fmt.Printf("Error retrieving %s: %s\n", n.Id, err.Error())
} else {
n.PP()
}
case "download":
if len(args) < 2 {
helpf("download requires <id>")
}
index := conf.Flags["index"]
parts := conf.Flags["parts"]
indexOptions := conf.Flags["index_options"]
opts := lib.Opts{}
if ne(index) || ne(parts) || ne(indexOptions) {
if ne(index) && ne(parts) {
opts["index"] = (*index)
opts["parts"] = (*parts)
if ne(indexOptions) {
opts["index_options"] = (*indexOptions)
}
} else {
helpf("index and parts options must be used together")
}
}
n := lib.Node{Id: args[1]}
if ih, err := n.Download(opts); err != nil {
fmt.Printf("Error downloading %s: %s\n", n.Id, err.Error())
} else {
//.........這裏部分代碼省略.........