Exposing API: Interface vs Struct
reddit.com·12h·
Discuss: r/golang
🔧API Design
Preview
Report Post

Hello everyone, I'm making a game engine in Go and I have a question about exposing the API.

This API is what allows developers to define the behaviors of their game and/or software. Despite being far into the development, I was never been able to figure out how to expose the API in a good way and I'm stuck on whether to expose an interface or struct.

I tried both approaches and they have their own pros and cons. So, I wanted to ask for your opinion on which approach is the most "Go" for these kinds of problems.

I have the following behaviors: - Load/OnSpawn : When the game is started. - Unload/OnDespawn : When the game engine swap contexs. - Destroy/OnDispose : When the game is terminated. - Draw : A call for each fr...

Similar Posts

Loading similar posts...