mirror of
https://github.com/rclone/rclone.git
synced 2024-12-19 21:51:51 +01:00
5d6b8141ec
As of Go 1.16, the same functionality is now provided by package io or package os, and those implementations should be preferred in new code.
38 lines
861 B
Go
38 lines
861 B
Go
// Package data provides utilities for DLNA server.
|
|
// The "go:generate" directive compiles static assets by running assets_generate.go
|
|
//
|
|
//go:generate go run assets_generate.go
|
|
package data
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"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 := io.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
|
|
}
|