本文整理汇总了Golang中github.com/go-ini/ini.File.WriteTo方法的典型用法代码示例。如果您正苦于以下问题:Golang File.WriteTo方法的具体用法?Golang File.WriteTo怎么用?Golang File.WriteTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/go-ini/ini.File
的用法示例。
在下文中一共展示了File.WriteTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
var ini_cfg *ini.File
var err error
if _, err = isExists(ANSIBLE_CMD); err != nil {
ANSIBLE_CMD = "ansible-playbook"
}
if *version {
fmt.Printf("%s: %s\n", os.Args[0], VERSION)
os.Exit(retOk)
}
if *operation_file == "" || *inventory_file == "" {
fmt.Printf("[ERROR] Not supported action: %s\n", action)
//gLogger.Error("operation and inventory file must provide.\n")
flag.Usage()
os.Exit(retFailed)
} else {
ret := checkExistFiles(*operation_file, *inventory_file)
if !ret {
fmt.Printf("[ERROR] check exists of operation and inventory file.\n")
//gLogger.Error("check exists of operation and inventory file.\n")
os.Exit(retInvaidArgs)
}
}
if action == "" {
fmt.Printf("[ERROR] action(check,update,deploy,rollback) must provide one.\n\n")
//gLogger.Error("action(check,update,deploy,rollback) must provide one.\n")
flag.Usage()
os.Exit(retInvaidArgs)
}
if *retry_file != "" {
if *retry_file, err = filepath.Abs(*retry_file); err != nil {
panic(fmt.Errorf("get Abs path of %s failed: %s\n", *retry_file, err))
//gLogger.Error("get Abs path of %s failed: %s\n", *retry_file, err)
os.Exit(retInvaidArgs)
}
}
if *inventory_file, err = filepath.Abs(*inventory_file); err != nil {
panic(fmt.Errorf("get Abs path of %s failed: %s\n", *inventory_file, err))
} else {
ini_cfg, err = ini.Load(*inventory_file)
if err != nil {
panic(fmt.Errorf("ini load conf failed: %s\n", err))
}
}
if *operation_file, err = filepath.Abs(*operation_file); err != nil {
panic(fmt.Errorf("get Abs path of %s failed: %s\n", *operation_file, err))
}
fmt.Printf("[%s] action on [%s]\n", action, *operation_file)
//gLogger.Info("[%s] action on [%s]\n", action, *operation_file)
switch action {
case "check":
fmt.Printf("-------------Now doing in action: %s\n", action)
//gLogger.Info("-------------Now doing in action: %s\n", action)
fmt.Printf("inventory: %s\n", *inventory_file)
ini_cfg.WriteTo(os.Stdout)
fmt.Println("")
opYamlSyntaxCheck(action, *inventory_file, *operation_file, *extra_vars, "all")
displayYamlFile(*operation_file)
case "update":
fmt.Printf("-------------Now doing in action: %s\n", action)
//gLogger.Info("-------------Now doing in action: %s\n", action)
doUpdateAction(action, *inventory_file, *operation_file, *program_version, *concurrent)
case "deploy":
fmt.Printf("-------------Inventory file is: %s\n", *inventory_file)
//gLogger.Info("-------------Inventory file is: %s\n", *inventory_file)
fmt.Printf("inventory: %s\n", *inventory_file)
ini_cfg.WriteTo(os.Stdout)
fmt.Printf("-------------Now doing in action:[%s], single mode:[%t]\n", action, *single_mode)
doDeployAction(action, *inventory_file, *operation_file, *single_mode, *concurrent, *retry_file, *extra_vars, *section)
case "rollback":
fmt.Printf("-------------Now doing in action: %s\n", action)
//gLogger.Info("-------------Now doing in action: %s\n", action)
fmt.Println("rollback action do nothing now.")
default:
fmt.Printf("Not supported action: %s\n", action)
//gLogger.Info("Not supported action: %s\n", action)
os.Exit(retFailed)
}
}