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

wrong pb package name in goctl rpc service generation #4552

Open
MYHZ79 opened this issue Jan 7, 2025 · 0 comments
Open

wrong pb package name in goctl rpc service generation #4552

MYHZ79 opened this issue Jan 7, 2025 · 0 comments

Comments

@MYHZ79
Copy link

MYHZ79 commented Jan 7, 2025

Describe the bug
wrong proto.PbPackage parameter in call.tpl name on generating rpc service by goctl

To Reproduce
Steps to reproduce the behavior, if applicable:

  1. this is part of my proto definition:
syntax = "proto3";

package ipncore;

option go_package = ".;ipncore";

// empty message
message Empty {}

// Common types
message Subnet {
    string id = 1;
    string name = 2;
    string cidr_block = 3;
}

// Request types
message ListSubnetsRequest {}

// Response types
message ListSubnetsResponse {
    repeated Subnet subnets = 1;
}

// Subnet-related service group
service SubnetService {
    rpc ListSubnets(ListSubnetsRequest) returns (ListSubnetsResponse);
}

and my package name in go.mod file is git.chinternal.com/ipn/ipn-core

  1. this is the genrated rpc service code in some files:

testrpc/client/subnetservice/subnetservice.go

   // Code generated by goctl. DO NOT EDIT.
// goctl 1.7.3
// Source: testrpc.proto

package subnetservice

import (
	"context"

	"git.chinternal.com/ipn/ipn-testrpc/pb"

	"github.com/zeromicro/go-zero/zrpc"
	"google.golang.org/grpc"
)

type (
	Empty               = ___ipncore.Empty
	ListSubnetsRequest  = ___ipncore.ListSubnetsRequest
	ListSubnetsResponse = ___ipncore.ListSubnetsResponse
	Subnet              = ___ipncore.Subnet

	SubnetService interface {
		ListSubnets(ctx context.Context, in *ListSubnetsRequest, opts ...grpc.CallOption) (*ListSubnetsResponse, error)
	}

	defaultSubnetService struct {
		cli zrpc.Client
	}
)

func NewSubnetService(cli zrpc.Client) SubnetService {
	return &defaultSubnetService{
		cli: cli,
	}
}

func (m *defaultSubnetService) ListSubnets(ctx context.Context, in *ListSubnetsRequest, opts ...grpc.CallOption) (*ListSubnetsResponse, error) {
	client := ___ipncore.NewSubnetServiceClient(m.cli.Conn())
	return client.ListSubnets(ctx, in, opts...)
}

Expected behavior
i think the name of pb package in these files must be ipncore instead of ___ipncore:
testrpc/internal/logic/subnetservice/listsubnetslogic.go testrpc/testrpc.go testrpc/client/subnetservice/subnetservice.go testrpc/internal/server/subnetservice/subnetserviceserver.go
Screenshots

Environments (please complete the following information):

  • OS: ubuntu 22.04
  • go-zero version 1.7.6
  • goctl version 1.7.5
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

No branches or pull requests

1 participant