Skip to content
This repository was archived by the owner on Mar 20, 2025. It is now read-only.
This repository was archived by the owner on Mar 20, 2025. It is now read-only.

Define interface in gamen package #13

Description

@kanryu

@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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions