veandco / go-sdl2

SDL2 binding for Go
https://godoc.org/github.com/veandco/go-sdl2
BSD 3-Clause "New" or "Revised" License
2.17k stars 219 forks source link

Readme Example Fix typo #592

Closed horw closed 3 months ago

horw commented 4 months ago

Go version: 1.21.3 Go-SDL2 version: v0.4.38 SDL2 version: OS: Architecture:

Hello!

It seems like there are some typos in the example you provided in README.md.

      for running {
        for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
            switch event.(type) {
            case sdl.QuitEvent:
                println("Quit")
                running = false
                break
            }
        }
    }

In the corrected code, I changed sdl.QuitEvent to *sdl.QuitEvent in the case statement to match the correct type. I hope this helps!

veeableful commented 4 months ago

Hi @horw, the example without asterisk in the event type is for the master branch which is bound for v0.5.x. It seems like you're using v0.4.x which uses asterisk. I will add a comment to the example in the README to make it clear.

horw commented 4 months ago

I see! @veeableful, Thank you!