initial commit
This commit is contained in:
32
core/data-clip-builder.go
Normal file
32
core/data-clip-builder.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
type DataClipBuilder struct {
|
||||
path string
|
||||
type_ any
|
||||
}
|
||||
|
||||
func (receiver *DataClipBuilder) InFile(filename string) {
|
||||
wd, _ := os.Getwd()
|
||||
receiver.path = filepath.Join(wd, filename)
|
||||
}
|
||||
|
||||
func (receiver *DataClipBuilder) UnderDir(dirpath string, filename string) {
|
||||
receiver.path = filepath.Join(dirpath, filename)
|
||||
}
|
||||
|
||||
func (receiver *DataClipBuilder) RegisterType(data interface{}) {
|
||||
receiver.type_ = reflect.New(reflect.TypeOf(data)).Interface()
|
||||
}
|
||||
|
||||
func (receiver *DataClipBuilder) Build() DataClip {
|
||||
return DataClip{
|
||||
path: receiver.path,
|
||||
type_: receiver.type_,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user