From 198ae53526b45a5ed3db672deac0c6d2e94ead71 Mon Sep 17 00:00:00 2001 From: suraj Date: Sun, 24 Sep 2023 15:02:57 +0530 Subject: [PATCH 1/2] os.Dir is not usefull in case of non-linux base os --- generator/write_strategy/file.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/write_strategy/file.go b/generator/write_strategy/file.go index c49c055..5f1a89a 100644 --- a/generator/write_strategy/file.go +++ b/generator/write_strategy/file.go @@ -36,7 +36,7 @@ func (s createFileStrategy) Write(renderer Renderer) error { if err != nil { return fmt.Errorf("unable to resolve path: %v", err) } - dir := path.Dir(outpath) + dir := filepath.Dir(outpath) _, err = os.Stat(dir) From 728d23473ecdf15aeade0a7ddb35e085fb94a0dd Mon Sep 17 00:00:00 2001 From: suraj Date: Sun, 24 Sep 2023 15:52:24 +0530 Subject: [PATCH 2/2] changed depricated packages --- generator/template/common.go | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/generator/template/common.go b/generator/template/common.go index 0d56cfd..bdc077b 100644 --- a/generator/template/common.go +++ b/generator/template/common.go @@ -16,7 +16,7 @@ import ( const ( PackagePathGoKitEndpoint = "github.com/go-kit/kit/endpoint" PackagePathContext = "context" - PackagePathGoKitLog = "github.com/go-kit/kit/log" + PackagePathGoKitLog = "github.com/go-kit/log" PackagePathTime = "time" PackagePathGoogleGRPC = "google.golang.org/grpc" PackagePathGoogleGRPCStatus = "google.golang.org/grpc/status" @@ -27,7 +27,7 @@ const ( PackagePathGoKitTransportHTTP = "github.com/go-kit/kit/transport/http" PackagePathBytes = "bytes" PackagePathJson = "encoding/json" - PackagePathIOUtil = "io/ioutil" + PackagePathIOUtil = "io" PackagePathIO = "io" PackagePathStrings = "strings" PackagePathUrl = "net/url" @@ -191,8 +191,7 @@ func nameOfLastResultError(fn *types.Function) string { // Renders struct field. // -// Visit *entity.Visit `json:"visit"` -// +// Visit *entity.Visit `json:"visit"` func structField(ctx context.Context, field *types.Variable) *Statement { s := structFieldName(field) s.Add(fieldType(ctx, field.Type, false)) @@ -205,8 +204,7 @@ func structField(ctx context.Context, field *types.Variable) *Statement { // Renders func params for definition. // -// visit *entity.Visit, err error -// +// visit *entity.Visit, err error func funcDefinitionParams(ctx context.Context, fields []types.Variable) *Statement { c := &Statement{} c.ListFunc(func(g *Group) { @@ -219,8 +217,7 @@ func funcDefinitionParams(ctx context.Context, fields []types.Variable) *Stateme // Renders field type for given func field. // -// *repository.Visit -// +// *repository.Visit func fieldType(ctx context.Context, field types.Type, allowEllipsis bool) *Statement { c := &Statement{} imported := false @@ -277,9 +274,8 @@ func interfaceType(ctx context.Context, p *types.Interface) (code []Code) { // Renders key/value pairs wrapped in Dict for provided fields. // -// Err: err, -// Result: result, -// +// Err: err, +// Result: result, func dictByVariables(fields []types.Variable) Dict { return DictFunc(func(d Dict) { for _, field := range fields { @@ -290,8 +286,7 @@ func dictByVariables(fields []types.Variable) Dict { // Render list of function receivers by signature.Result. // -// Ans1, ans2, AnS3 -> ans1, ans2, anS3 -// +// Ans1, ans2, AnS3 -> ans1, ans2, anS3 func paramNames(fields []types.Variable) *Statement { var list []Code for _, field := range fields { @@ -306,8 +301,7 @@ func paramNames(fields []types.Variable) *Statement { // Render full method definition with receiver, method name, args and results. // -// func (e *Endpoints) Count(ctx context.Context, text string, symbol string) (count int) -// +// func (e *Endpoints) Count(ctx context.Context, text string, symbol string) (count int) func methodDefinition(ctx context.Context, obj string, signature *types.Function) *Statement { return Func(). Params(Id(rec(obj)). /*.Op("*")*/ Id(obj)). @@ -322,8 +316,7 @@ func methodDefinitionFull(ctx context.Context, obj string, signature *types.Func // Render full method definition with receiver, method name, args and results. // -// func Count(ctx context.Context, text string, symbol string) (count int) -// +// func Count(ctx context.Context, text string, symbol string) (count int) func functionDefinition(ctx context.Context, signature *types.Function) *Statement { return Id(signature.Name). Params(funcDefinitionParams(ctx, signature.Args)).