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

Workaround for static libraries breaks `go get -u` #557

Closed ptxmac closed 1 year ago

ptxmac commented 1 year ago

After 9515279986a1fc8d043e301522c565a0b8b56480 it's no longer possible to update all dependencies in a project that use go-sdl2.

Normally this would be done by running go get -u ./..., but after the dummy package was added the go command fails:

go: malformed module path "github.com/veandco/go-sdl2/.go-sdl2-libs": leading dot in path element
go: malformed module path "github.com/veandco/go-sdl2/.go-sdl2-libs/include/SDL2": leading dot in path element

Go version: 1.20.2 Go-SDL2 version: 0.4.33 OS: macos Architecture: arm64

veeableful commented 1 year ago

Hi @ptxmac, thanks for reporting this issue! Sorry for taking so long to reply as I'm out of town. I will try to implement a solution around end of next week once I'm back, perhaps by renaming the directories. Will post an update here then!

ptxmac commented 1 year ago

Any update? I think it would be fine if we just replace the . with _

veeableful commented 1 year ago

Hi @ptxmac, sorry I was actually just starting to work on this! Could you let me know how I can reproduce the issue? I might just end up following your suggestion in order to fix it.

ptxmac commented 1 year ago

Sure, create a new project that use go modules. E.g.

main.go:

package main

import "github.com/veandco/go-sdl2/sdl"

func main() {
    sdl.GetRevision()
}

and go.mod:

module github.com/ptxmac/go-sdl2-get-bug

go 1.20

require github.com/veandco/go-sdl2 v0.4.33

Then run go get -u

veeableful commented 1 year ago

That's strange.. go get -u succeeded for me using the same configuration as yours. Is there something else that I should do?

ptxmac commented 1 year ago

Perhaps you're using a different version of go? This bug appears on go1.20

I've created a quick sample project here: https://github.com/ptxmac/go-sdl2-get-bug

veeableful commented 1 year ago

My Go version is go version go1.20.2 darwin/arm64. I cloned the sample project and ran go get -u there as well but it didn't produce any error.

ptxmac commented 1 year ago

Very strange, I'm using go version go1.20.3 darwin/arm64 But I also saw it on v1.20.2

Maybe if you use go get -u ./... instead?

veeableful commented 1 year ago

I tried with go get -u ./... but the error doesn't show up. I will keep trying to see if I can reproduce it.

ptxmac commented 1 year ago

Very strange... perhaps try removing go-sdl from the mod cache in go env GOMODCACHE

veeableful commented 1 year ago

It still runs fine...I also tried with a new macOS user with an empty home directory.

ptxmac commented 1 year ago

So apparently it's something with my setup - I just tried an empty user, and there it works fine... 🙃

veeableful commented 1 year ago

Oh... if you happen to find the cause, please let me know! I would be interested to know why that error happened and perhaps add that information to the README.

ptxmac commented 1 year ago

Yeah, I've found the code that returns the error, and from what I can understand it "should" be illegal to use dots because it might conflict with VCS systems.

But why that code is only getting triggered by my setup is very strange!

ptxmac commented 1 year ago

I figured it out!

I had to step through go get in a debugger, but finally discovered the difference. I have GONOPROXY configured!

From my understanding the go get command will look up modules on a proxy server to avoid putting too much load on the repository. If GONOPROXY is set it will go directly to the repository instead.

I guess the proxy server ignores files starting with a dot when it indexes a repository.

You can test it out with GONOPROXY=test go get -u

ptxmac commented 1 year ago

It also happens if GONOSUMDB is set. Basically if you have a project that depends on private packages, then it will break

veeableful commented 1 year ago

Hi @ptxmac, thank you very much for finding the way to reproduce it! I renamed the .go-sdl2-libs directory to _libs and pushed that change to the test branch. It seems to work for me so let me know if it works for you too. I will tag a new version once it's confirmed to fix it 🙂

ptxmac commented 1 year ago

Works perfect for me too!

veeableful commented 1 year ago

Okay, I have pushed the tag v0.4.34!