Skip to content

wrong pb package name in goctl rpc service generation #4552

@MYHZ79

Description

@MYHZ79

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions