vise/go/resource/fs.go

41 lines
738 B
Go
Raw Normal View History

2023-03-31 11:52:04 +02:00
package resource
import (
"context"
2023-04-01 11:58:02 +02:00
"fmt"
"io/ioutil"
"path"
"strings"
2023-03-31 11:52:04 +02:00
)
type FsResource struct {
path string
ctx context.Context
}
func NewFsResource(path string, ctx context.Context) (FsResource) {
return FsResource{
path: path,
ctx: ctx,
}
}
2023-04-01 11:58:02 +02:00
func(fs FsResource) GetTemplate(sym string) (string, error) {
fp := path.Join(fs.path, sym)
r, err := ioutil.ReadFile(fp)
s := string(r)
return strings.TrimSpace(s), err
2023-03-31 11:52:04 +02:00
}
2023-04-01 11:58:02 +02:00
func(fs FsResource) RenderTemplate(sym string, values map[string]string) (string, error) {
2023-03-31 11:52:04 +02:00
return "", nil
}
2023-04-01 11:58:02 +02:00
func(fs FsResource) GetCode(sym string) ([]byte, error) {
return []byte{}, nil
}
func(fs FsResource) FuncFor(sym string) (EntryFunc, error) {
return nil, fmt.Errorf("not implemented")
}