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

Define interface in gamen package #13

Open
kanryu opened this issue Feb 24, 2024 · 0 comments
Open

Define interface in gamen package #13

kanryu opened this issue Feb 24, 2024 · 0 comments

Comments

@kanryu
Copy link

kanryu commented Feb 24, 2024

@rajveermalviya Hi,

As recommended by the Go language, if a struct with methods satisfies an interface, you should indicate that in your code.

So the code is like this.

package win32
import (
"github.com/rajveermalviya/gamen"
)
var _ gamen.Window = (*Window)(nil)
type Window struct {
}

Currently, important interfaces such as Display and Window are defined in the display package.
However, the display package must define an important function called display.NewDisplay(). You will then refer to the concrete implementation (e.g. win32.NewDisplay()).
Therefore, if an interface is defined within the display package, the display package cannot be referenced from environment-dependent packages (e.g. win32). This is because cross-package references occur.
To prevent this problem, separate display.NewDisplay() and interface definition packages. Simply add the gamen package and define the interface there.

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

1 participant