本文整理匯總了Golang中github.com/fuxiaohei/GoInk.App.View方法的典型用法代碼示例。如果您正苦於以下問題:Golang App.View方法的具體用法?Golang App.View怎麽用?Golang App.View使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/fuxiaohei/GoInk.App
的用法示例。
在下文中一共展示了App.View方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: DoBackup
// DoBackup backups whole files to zip archive.
// If withData is false, it compresses static files to zip archive without data files, config files and install lock file.
func DoBackup(app *GoInk.App, withData bool) (string, error) {
os.Mkdir(backupDir, os.ModePerm)
// create zip file name from time unix
filename := path.Join(backupDir, utils.DateTime(time.Now(), "YYYYMMDDHHmmss"))
if withData {
filename += ".zip"
} else {
filename += "_static.zip"
}
z, e := zip.Create(filename)
if e != nil {
return "", e
}
root, _ := os.Getwd()
if withData {
// if with data, add install lock file and config file
lockFile := path.Join(root, "install.lock")
if utils.IsFile(lockFile) {
z.AddFile("install.lock", lockFile)
}
configFile := path.Join(root, "config.json")
if utils.IsFile(configFile) {
z.AddFile("config.json", configFile)
}
}
z.AddDir("static/css", path.Join(root, "static", "css"))
z.AddDir("static/img", path.Join(root, "static", "img"))
z.AddDir("static/js", path.Join(root, "static", "js"))
z.AddDir("static/lib", path.Join(root, "static", "lib"))
z.AddFile("static/favicon.ico", path.Join(root, "static", "favicon.ico"))
if withData {
// if with data, backup data files and uploaded files
z.AddDir("data", path.Join(root, "data"))
z.AddDir("static/upload", path.Join(root, "static", "upload"))
}
z.AddDir(app.View().Dir, path.Join(root, app.View().Dir))
e = z.Flush()
if e != nil {
return "", e
}
println("backup success in " + filename)
return filename, nil
}