feat: use viper and cobra to parameterize creation values with viper yaml

This commit is contained in:
2023-02-15 19:30:05 +01:00
parent 0019941054
commit c1680106ab
8 changed files with 722 additions and 2 deletions

5
pkg/io/writer.go Normal file
View File

@@ -0,0 +1,5 @@
package io
type WriterIface interface {
WriteFile(filename string, data []byte) (string, error)
}

View File

@@ -1,6 +1,8 @@
package util
import (
"bytes"
"encoding/gob"
"log"
"os/exec"
"strings"
@@ -16,3 +18,13 @@ func RootDir() string {
rootDir := strings.TrimSpace(string(cmdOut))
return rootDir
}
func GetBytes(key interface{}) ([]byte, error) {
var buf bytes.Buffer
enc := gob.NewEncoder(&buf)
err := enc.Encode(key)
if err != nil {
return nil, err
}
return buf.Bytes(), nil
}