Skip to content

fix: handle package name without dot to prevent index out of range#78

Open
yashisrani wants to merge 1 commit into
gofr-dev:mainfrom
yashisrani:fix/grpc-index
Open

fix: handle package name without dot to prevent index out of range#78
yashisrani wants to merge 1 commit into
gofr-dev:mainfrom
yashisrani:fix/grpc-index

Conversation

@yashisrani

@yashisrani yashisrani commented Jun 1, 2026

Copy link
Copy Markdown

Description

Fixes a potential index out of range panic in wrap/grpc.go when parsing proto files where the package name doesn't contain a dot.

Problem

When packageName has no dot (e.g., "mypackage"), strings.LastIndex returns -1, causing packageName[lastPiece+1:] to slice incorrectly and produce wrong output.

Solution

Added a check for lastPiece == -1 to handle package names without dots, ensuring correct slice indexing in all cases.

Changes

  • wrap/grpc.go:471-478 - Fixed import alias extraction logic

Testing

  • All existing tests pass
  • Build compiles successfully

@yashisrani

yashisrani commented Jun 1, 2026

Copy link
Copy Markdown
Author

cc @coolwednesday @aryanmehrotra

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant