Hello World
Hello World Example
Installing the module
go install graphics.gd/cmd/gd@master
Create a new go project
go mod init main
Create a new main.go file
package main
import ( "fmt"
"graphics.gd/classdb" "graphics.gd/classdb/Node2D" "graphics.gd/startup")
type HelloWorld struct { classdb.Extension[HelloWorld, Node2D.Instance]}
// Ready implements the Godot Node2D _ready interface (virtual function).func (h *HelloWorld) Ready() { fmt.Println("Hello World from Go!")}
func main() { classdb.Register[HelloWorld]() startup.Engine()}
Use go get -u
to make sure the project and all the dependencies are up to date.
go get -u
run the project
gd
With godot editor running add the HelloWorld
Node to the the node in the current scene and save the project and close it.
Add it to the scene tree.
Save the project in Godot Editor.
In godot run the project or by running gd run
in your terminal.
You may need to close and open the godot editor using gd
if it cannot map the assets in the project.
If all is well check the editor and you should see the message Hello World from Go!
in the console of your code editor.