Unable to use FileAccess.Open
mdevnull opened this issue · 1 comments
mdevnull commented
FileAccess Open methods is a static factory method but as go does not support static methods it requires to already have an instance of FileAccess.
Given the following example code
var fa gd.FileAccess
readFileFa := fa.Open(godoCtx, godoCtx.String("user://a_file.txt"), gd.FileAccessModeFlags(1))
I get the following error
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x20 pc=0x7ff9840e1722]
goroutine 7 [running]:
grow.graphics/gd/internal/classdb.FileAccess.Open({{}, {{}, {0x0?, 0x0?}}}, {{0x7ff985e05600?, 0x1c0007582a0?}, 0x7ff98) C:/Users/***/go/pkg/mod/grow.graphics/gd@v0.0.0-20240621210912-65385949944f/internal/classdb/all.go:56339 +0x2
As A workaround I will use golangs io package but letting the engine handle the final file path resolution would be nice.
Splizard commented
Both your example and the below example should now work with static methods:
file := gd.FileAccess.Open(gd.FileAccess{}, godot, godot.String("user://a_file.txt"), gd.FileAccessRead)