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

add feature for check custom interfaces described in ruleguard rules #316

Open
peakle opened this issue Dec 21, 2021 · 1 comment
Open

Comments

@peakle
Copy link
Contributor

peakle commented Dec 21, 2021

add feature for check local described interfaces in rules or in the same repo

@quasilyte
Copy link
Owner

I would start from allowing inline interfaces:

Type.Implements(<inline interface>)

Like
Type.Implements(`interface{String() string}`)

For more complex cases one could use a constant:

const dbInterface = `interface{
  Query(query string, args ...interface{}) (*sql.Rows, error)
  Close() error
}`

Note that types like sql.Rows will be resolved in the context of the current rule. This will make it possible to reference types outside of the stdlib by using dsl.Import before using Type.Implements on the string that refers to these external types.

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