mirror of
https://github.com/rclone/rclone.git
synced 2024-11-25 18:04:55 +01:00
e43b5ce5e5
This is possible now that we no longer support go1.12 and brings rclone into line with standard practices in the Go world. This also removes errors.New and errors.Errorf from lib/errors and prefers the stdlib errors package over lib/errors.
37 lines
818 B
Go
37 lines
818 B
Go
//go:generate go run assets_generate.go
|
|
// The "go:generate" directive compiles static assets by running assets_generate.go
|
|
|
|
package data
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"text/template"
|
|
|
|
"github.com/rclone/rclone/fs"
|
|
)
|
|
|
|
// GetTemplate returns the rootDesc XML template
|
|
func GetTemplate() (tpl *template.Template, err error) {
|
|
templateFile, err := Assets.Open("rootDesc.xml.tmpl")
|
|
if err != nil {
|
|
return nil, fmt.Errorf("get template open: %w", err)
|
|
}
|
|
|
|
defer fs.CheckClose(templateFile, &err)
|
|
|
|
templateBytes, err := ioutil.ReadAll(templateFile)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("get template read: %w", err)
|
|
}
|
|
|
|
var templateString = string(templateBytes)
|
|
|
|
tpl, err = template.New("rootDesc").Parse(templateString)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("get template parse: %w", err)
|
|
}
|
|
|
|
return
|
|
}
|