From cfb43ba21d5d0035243b26650219435c8d10c7ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulo=20Sima=CC=83o?= Date: Mon, 6 Sep 2021 10:31:56 -0300 Subject: [PATCH] Recovering operational --- go.mod | 1 - lib/config.go | 19 ------------------- lib/main.go | 6 ------ lib/processGoClientOutput.go | 2 +- lib/processGoServerOutput.go | 12 ++++++------ 5 files changed, 7 insertions(+), 33 deletions(-) delete mode 100644 lib/config.go diff --git a/go.mod b/go.mod index 52b4626..3a1191f 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.17 require ( github.com/alecthomas/kong v0.2.15 github.com/fatih/structtag v1.2.0 - github.com/gin-gonic/gin v1.6.3 github.com/pkg/errors v0.9.1 gopkg.in/yaml.v2 v2.4.0 ) diff --git a/lib/config.go b/lib/config.go deleted file mode 100644 index fe4ff67..0000000 --- a/lib/config.go +++ /dev/null @@ -1,19 +0,0 @@ -package lib - -//type Config struct { -// Gofname string `yaml:"gofname"` -// Goimpldir string `yaml:"goimpldir"` -// Tsfname string `json:"tsfname"` -// Goclifname string `json:"goclifname"` -//} -// -//var config Config -// -//func loadConfig() { -// fname := flag.String("f", ".apigen.yaml", "File with config to load - defaults to '.apigen'") -// flag.Parse() -// bs, err := ioutil.ReadFile(*fname) -// Err(err) -// err = yaml.Unmarshal(bs, &config) -// Err(err) -//} diff --git a/lib/main.go b/lib/main.go index 16fdb94..c0d8860 100644 --- a/lib/main.go +++ b/lib/main.go @@ -112,10 +112,4 @@ func Run() { if err != nil { panic(err) } - //loadConfig() - // - - //os.Remove(config.Gofname) - - //process(&api) } diff --git a/lib/processGoClientOutput.go b/lib/processGoClientOutput.go index 2c26894..a38b9e1 100644 --- a/lib/processGoClientOutput.go +++ b/lib/processGoClientOutput.go @@ -122,7 +122,7 @@ func invoke(m string, path string, bodyo interface{}) (*json.Decoder, error) { for k, v := range api.Methods { WNL(`func %s(req %s) (res %s, err error){`, k, ResDecType(v.ReqType), ResDecType(v.ResType)) WNL(` var dec *json.Decoder - dec, err = invoke("%s", "%s", res) + dec, err = invoke("%s", "%s", req) if err!=nil{ return } diff --git a/lib/processGoServerOutput.go b/lib/processGoServerOutput.go index 18ab005..bcad8d4 100644 --- a/lib/processGoServerOutput.go +++ b/lib/processGoServerOutput.go @@ -64,15 +64,15 @@ func processGoServerOutput(f string) error { WNL(` default: http.Error(w,"Method not allowed",500)`) + + WNL(` }`) } - - WNL(` }`) - - WNL(` }) - return ret - }`) + WNL(` })`) } + WNL(` return ret + } +`) for _, v := range api.Methods { WNL(`func h_%s(w http.ResponseWriter, r *http.Request) {