This will be a living doc which will provide an overview of key concepts in the godot-go bidnings.
There are a lot of language features supported by GDScript that does not map cleanly to Go.
Default parameters are currently not supported.
Go does not support classical class inheritance. Instead, composition with struct embedding is used in it's place. Lets take a look at the following example user-defined class:
type PlayerCharacter struct {
CharacterBody2DImpl
}
// interface test evidence
var _ CharacterBody2D = &PlayerCharacter{}
The user-defined PlayerCharacter
class extends the CharacterBody2D
interface by embedding the CharacterBody2DImpl
struct. Following the definition of CharacterBody2DImpl
we see the following definition:
type CharacterBody2DImpl struct {
PhysicsBody2DImpl
}
We see that CharacterBody2DImpl
embeds the PhysicsBody2DImpl
struct, which implements the PhysicsBody2D
interface.
Go does not natively support virtual functions or struct methods. Insteead, a method name prefix convention will be implemented. The current implementation ignores all virtual methods on existing Godot classes.
func (e *Example) V_Ready() { ... }
...
// register the function with Godot
ClassDBBindMethodVirtual(t, "V_Ready", "_ready", nil, nil)
(NOT YET IMPLEMENTED) The eventual best practice will be the following example:
func (e *Example) V_Example_Ready() { ... }
...
// register the function with Godot
ClassDBBindMethodVirtual(t, "V_Example_Ready", "_ready", nil, nil)
V_
denotes this this is a virtual function.Example_
matches the name of the class. godot-go should panic if the registered method does not follow this pattern.Ready
matches_ready
gdscript method.
Go does not support default parameter values. Default argument will show up in the godocs comments, but it will not be implemented directly in the code.
Go does not support static methods in structs. Registering static methods is not supported.
Go does not support static variables in structs. (NOT YET IMPLEMENTED) Global variables can be registered as gdscript static variables.
Works fine and partially tested in the tests.
Go does not support coroutines; this means we do not have acess to await
(or yield
). Without a coroutine alternative, a cumbersome pattern of chaining method calls will be required. (NOT YET IMPLEMENTED) Instead, we have goroutines to wrap signal
and callable
.
GDScript Type | Go Type | Description |
---|---|---|
null |
nil |
|
bool |
bool |
|
int |
int64 |
All method parameters that use variations of uint and int will be converted to int64 before passing over the value to Godot. |
float |
float64 |
float32 will convert to float64 before passing over the value to Godot. |
String |
String |
There are helper functions to convert to go native string . |
StringName |
StringName |
There are helper functions to convert to go native string . |
NodePath |
NodePath |
GDScript Type | Go Type |
---|---|
Vector2 |
Vector2 |
Vector2i |
Vector2i |
Rect2 |
Rect2 |
Vector3 |
Vector3 |
Vector3i |
Vector3i |
Transform2D |
Transform2D |
Plane |
Plane |
Quaternion |
Quaternion |
AABB |
AABB |
Basis |
Basis |
Transform3D |
Transform3D |
GDScript Type | Go Type |
---|---|
Color |
Color |
RID |
RID |
Object |
Object |
GDScript Type | Go Type | Description |
---|---|---|
Array |
Array |
(NOT YET IMPLEMENTED) []Variant . |
PackedByteArray |
PackedByteArray |
(NOT YET IMPLEMENTED) []byte . |
PackedInt32Array |
PackedInt32Array |
(NOT YET IMPLEMENTED) []int32 . |
PackedInt64Array |
PackedInt64Array |
(NOT YET IMPLEMENTED) []int64 . |
PackedFloat32Array |
PackedFloat32Array |
(NOT YET IMPLEMENTED) []float32 . |
PackedFloat64Array |
PackedFloat64Array |
(NOT YET IMPLEMENTED) []float64 . |
PackedStringArray |
PackedStringArray |
(NOT YET IMPLEMENTED) []string . |
PackedVector2Array |
PackedVector2Array |
(NOT YET IMPLEMENTED) []Vector2 . |
PackedVector3Array |
PackedVector3Array |
(NOT YET IMPLEMENTED) []Vector3 . |
PackedColorArray |
PackedColorArray |
(NOT YET IMPLEMENTED) []color . |
Dictionary |
Dictionary |
No additional work needed. |
Signal |
Signal |
No additional work needed. |
Callable |
Callable |
No additional work needed. |