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: multiple files import the same api file #3642

Merged
merged 1 commit into from
Oct 23, 2023

Conversation

7134g
Copy link
Contributor

@7134g 7134g commented Oct 18, 2023

fixed: multiple files import the same api file

Program error prompt:
import cycle not allowed

But I didn't actually loop in the import file

reappear example:

execute: goctl api go -api base.api -dir ./api --style=go_zero

base.api

syntax = "v1"

import "admin_work.api"
import "admin_report.api"
import "admin_retain.api"

public.api

syntax = "v1"

type UserInfo struct {}
type WorkInfo struct {}

query.api

syntax = "v1"

type QueryPage struct {}

admin_report.api

syntax = "v1"

import "query.api"
import "public.api"

@server(
    prefix: report
)
service admin_svr {
    @handler ReportList
    post /list (ReportReq) returns (ReportResp)

}

type (
    ReportReq {
        QueryPage
    }

    ReportResp {
        WorkInfo
        UserInfo
    }
)

admin_retain.api

syntax = "v1"

import "query.api"

@server(
    prefix: retain
)
service admin_svr {
    @handler RetainList
    post /list (RetainListReq) returns (RetainListResp)
}


type (
    RetainListReq {
        QueryPage
    }
    RetainListResp {
    }
)

admin_work.api

syntax = "v1"

import "query.api"
import "public.api"

@server(
	prefix: work
)
service admin_svr {
	@handler WorkList
	post /list (WorkListRes) returns (WorkListResp)
}

type (
	WorkListRes {
		QueryPage
	}

	WorkListResp {
		WorkInfo
		UserInfo
	}
)

Copy link
Collaborator

@kesonan kesonan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kevwan kevwan added this pull request to the merge queue Oct 23, 2023
Merged via the queue into zeromicro:master with commit 117c3a9 Oct 23, 2023
6 checks passed
@kevwan kevwan added the area/api Categorizes issue or PR as related to API syntax or usages. label Oct 23, 2023
@6xiaowu9
Copy link

6xiaowu9 commented Dec 14, 2023

According to this import method, there will be no duplicate imports, but duplicate types will appear.

error: duplicate declaration: base.api 4:6 duplicate type expression

please help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api Categorizes issue or PR as related to API syntax or usages.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants