work on generating main.go and use config not hardcoded vals

This commit is contained in:
cubixle
2021-06-18 13:58:58 +01:00
parent feff0c38eb
commit f435f65536
10 changed files with 124 additions and 76 deletions
+7
View File
@@ -1,6 +1,8 @@
package tuugen
import (
"path/filepath"
"gopkg.in/yaml.v2"
)
@@ -9,9 +11,14 @@ type Config struct {
ServiceName string `yaml:"service_name"`
ImportPath string `yaml:"import_path"`
ProtoFile string `yaml:"proto_file"`
GRPCFile string `yaml:"grpc_file"`
DataModels []DataModel `yaml:"data_models"`
}
func (c Config) GRPCPath() string {
return filepath.Dir(c.GRPCFile)
}
func YamlToConfig(b []byte) (Config, error) {
cfg := Config{}
err := yaml.Unmarshal(b, &cfg)