feat: use viper and cobra to parameterize creation values with viper yaml
This commit is contained in:
5
pkg/io/writer.go
Normal file
5
pkg/io/writer.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package io
|
||||
|
||||
type WriterIface interface {
|
||||
WriteFile(filename string, data []byte) (string, error)
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user