Getting seriously tricky stuff done in Go is, time and again, surprisingly simple:
Here's an interesting "convoluted custom use-case" I just had while working on go:ngine. So the engine is supposed to support OpenGL versions 3.2 or higher, but during development, 99% of the time I just run under OpenGL 4.2. To stay in the flow, I don't want to consult the GL specs every time I use a GL function or enumeration. At the same time, when I push to GitHub, I'd like to make sure any and all GL function or enumeration references in all go:ngine sources are either GL 3.2 or lower, or else wrapped in some conditional logic (ie. "only go ahead here if client GL version supports it")...
So for talking to OpenGL, go:ngine uses the fantastic GoGL binding. Specifically it uses the gl42 sub-package -- don't worry, that package even works under OpenGL 3.2! --- at least, if we (A) ignore the version-related error (but not any other kind of error) returned by
gl42.Init() and (B) ensure we don't use API functions or enum values newer than the detected run-time GL version. So part (A) is easy, but ensuring (B) at all times (when mostly I happily develop using just my 4.2-capable GPU) could over time become an issue. What to do?
that I would run just occasionally -- every other week, or right before major commits. It would:
GL v4.2 used 4x:
GL v4.0 used 2x:
The above is actually real output of said tool, because I just wrote it today in just a few hours and guess what..
If you wanna see (or use) the code to parse the .go source tree, load the XML spec and checks any and all gogl/gl42 references across a given code-base against specific OpenGL versions, it's right here on GitHub.