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

Generates code from imported types #52

Open
smyrman opened this issue Feb 12, 2021 · 2 comments
Open

Generates code from imported types #52

smyrman opened this issue Feb 12, 2021 · 2 comments

Comments

@smyrman
Copy link

smyrman commented Feb 12, 2021

When running zenrpc in a package that both defines and imports a zenrpc.Service type, then it will generate (incorrect) code for the imported services.

I.e. if having:

cmd/mycmd
    main_zenrpc.go -- generated
    service.go -- defines FooService
    server.go -- register FooService and pkg/bar.Service
pkg/bar
   bar_zenrpc.go -- generated
   service.go -- defines Service

When generating the code in cmd/mycmd then it will generate code for Service (which does not exist in the package) as well as FooService, which does exist. It will also, for some reason, import encoding/json twise. Either way, the result is invalid code.

Maybe related with #35?

dizzyfool added a commit that referenced this issue Mar 23, 2021
@dizzyfool
Copy link
Collaborator

Should be working now, please confirm

@smyrman
Copy link
Author

smyrman commented Apr 26, 2021

Sorry for the late update. It seams that we no longer get the additional Service generation. However, we still get a duplicated import:

Import:

import (
	"context"
	"encoding/json"

	"github.com/semrush/zenrpc/v2"
	"github.com/semrush/zenrpc/v2/smd"

	"encoding/json"
)

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

2 participants