本文整理匯總了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)
}