Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go - Ctrl+D on terminal is not rasing #690

Open
ronaldoapsilva opened this issue Apr 16, 2024 · 0 comments
Open

Go - Ctrl+D on terminal is not rasing #690

ronaldoapsilva opened this issue Apr 16, 2024 · 0 comments
Labels

Comments

@ronaldoapsilva
Copy link

I have the following func below. After add the category I pressed Ctrl+D, but it didn't raise the error io.EOF to trigger stream.SendAndClose

To reproduce

func (c *CategoryService) CreateCategoryStream(stream pb.CategoryService_CreateCategoryStreamServer) error {
	categories := &pb.CategoryList{}

	for {
		category, err := stream.Recv()
		log.Println(category)	
		if err == io.EOF {
			return stream.SendAndClose(categories)
		}
		if err != nil {
			return err
		}

		categoryResult, err := c.CategoryDB.Create(category.Name, category.Description)
		if err != nil {
			return err
		}
		
		categories.Categories = append(categories.Categories, &pb.Category{
			Id:          categoryResult.ID,
			Name:        categoryResult.Name,
			Description: categoryResult.Description,
		})
		// log.Println(categories)		
	}
}

Expected behavior

Screenshots

image

Environment

  • OS: Ubuntu 22.04.4 LTS
  • GO: go 1.22.2
  • Terminal: bash
  • Evans version: 0.10.11
  • protoc version: libprotoc 3.12.4
  • protoc plugin version (if you are using):

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant