本文整理汇总了Golang中v/io/jiri/profiles.DB.Write方法的典型用法代码示例。如果您正苦于以下问题:Golang DB.Write方法的具体用法?Golang DB.Write怎么用?Golang DB.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类v/io/jiri/profiles.DB
的用法示例。
在下文中一共展示了DB.Write方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: writeDB
func writeDB(jirix *jiri.X, db *profiles.DB, installer, path string) error {
// Do nothing if the installer is not supplied. This will generally
// happen when/if writeDB is called from the top-level profile driver
// command rather than from a subcommand.
if installer == "" {
return nil
}
fi, err := os.Stat(path)
if err != nil {
if !os.IsNotExist(err) {
return err
}
// New setup, but the directory doesn't exist yet.
if err := os.MkdirAll(path, os.FileMode(0755)); err != nil {
return err
}
} else {
if !fi.IsDir() {
return fmt.Errorf("%s exists but is not a directory", path)
}
}
// New setup with installers writing their own file in a directory
return db.Write(jirix, installer, path)
}