From 84d8a58f8c92bffc63aa115d7a0dc6b54f3be5a0 Mon Sep 17 00:00:00 2001 From: Yash Israni <118755067+yashisrani@users.noreply.github.com> Date: Mon, 1 Jun 2026 11:18:50 +0530 Subject: [PATCH] fix: handle package name without dot to prevent index out of range --- wrap/grpc.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wrap/grpc.go b/wrap/grpc.go index 26b8cab..60d2218 100644 --- a/wrap/grpc.go +++ b/wrap/grpc.go @@ -469,7 +469,13 @@ func getImports(ctx *gofr.Context, definition *proto.Proto, protoPath string) [] } lastPiece := strings.LastIndex(packageName, ".") - formattedImport := fmt.Sprintf("%s %q", packageName[lastPiece+1:], packageSource) + if lastPiece == -1 { + lastPiece = 0 + } else { + lastPiece++ + } + + formattedImport := fmt.Sprintf("%s %q", packageName[lastPiece:], packageSource) imports = append(imports, formattedImport) } }