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

fix: didn't use alias when importing logic package in handler.go when groups are using for api generation. #2093

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zze326
Copy link

@zze326 zze326 commented Jul 4, 2022

No description provided.

@kesonan
Copy link
Collaborator

kesonan commented Jul 9, 2022

Thanks for your contribution, I checked the code generation of api again, it's unnecessary add an alias for group folder, for instance, there has an api file which contains part of content as following:

@server (
	group: test
)
service greet-api {
	@handler GreetHandler
	get /from/:name(Request) returns (Response)
}

the generated results' tree showing as following:

.
├── etc
│   └── greet-api.yaml
├── greet.api
├── greet.go
└── internal
    ├── config
    │   └── config.go
    ├── handler
    │   ├── routes.go
    │   └── test
    │       └── greethandler.go
    ├── logic
    │   └── test
    │       └── greetlogic.go
    ├── svc
    │   └── servicecontext.go
    └── types
        └── types.go

the handler's imports are

import (
	"net/http"

	"github.com/zeromicro/go-zero/rest/httpx"
	"go-zero-demo/greet/internal/logic/test"
	"go-zero-demo/greet/internal/svc"
	"go-zero-demo/greet/internal/types"
)

it works correctly. As your pr do, the imports should be

import (
	"net/http"

	"github.com/zeromicro/go-zero/rest/httpx"
	**logic** "go-zero-demo/greet/internal/logic/test"
	"go-zero-demo/greet/internal/svc"
	"go-zero-demo/greet/internal/types"
)

it's not a recommend solution.

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.

2 participants