This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch main
in repository ego.
View the commit online.
commit c4d4bc4608b6de5b6459162683bc9a2c4009c0fb
Author: [email protected] <[email protected]>
AuthorDate: Sun Mar 8 21:23:54 2026 -0600
feat: initialize ego Go bindings project with C string utilities
Add project scaffolding for ego, the Go bindings for the Enlightenment
Foundation Libraries (EFL). This includes the go.mod module definition
and the internal/cutil package which provides helpers for converting
between Go and C strings.
The cutil package implements three core functions:
- GoString: converts C char pointers to Go strings
- CString: allocates C strings from Go strings
- FreeString: properly deallocates C strings
Includes round-trip and empty string tests to verify correct behavior.
Co-Authored-By: Claude Code <[email protected]>
---
go.mod | 3 +++
internal/cutil/cutil.go | 22 ++++++++++++++++++++++
internal/cutil/cutil_test.go | 22 ++++++++++++++++++++++
3 files changed, 47 insertions(+)
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..338f72b
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,3 @@
+module git.enlightenment.org/cedric/ego
+
+go 1.26.1
diff --git a/internal/cutil/cutil.go b/internal/cutil/cutil.go
new file mode 100644
index 0000000..707fc00
--- /dev/null
+++ b/internal/cutil/cutil.go
@@ -0,0 +1,22 @@
+package cutil
+
+/*
+#include <stdlib.h>
+*/
+import "C"
+import "unsafe"
+
+// GoString converts a C string to Go string. Does not free the C string.
+func GoString(s *C.char) string {
+ return C.GoString(s)
+}
+
+// CString converts a Go string to a C string. Caller must free with FreeString.
+func CString(s string) *C.char {
+ return C.CString(s)
+}
+
+// FreeString frees a C string allocated by CString.
+func FreeString(s *C.char) {
+ C.free(unsafe.Pointer(s))
+}
diff --git a/internal/cutil/cutil_test.go b/internal/cutil/cutil_test.go
new file mode 100644
index 0000000..338ba3c
--- /dev/null
+++ b/internal/cutil/cutil_test.go
@@ -0,0 +1,22 @@
+package cutil
+
+import "testing"
+
+func TestCStringRoundTrip(t *testing.T) {
+ original := "hello world"
+ cs := CString(original)
+ defer FreeString(cs)
+ got := GoString(cs)
+ if got != original {
+ t.Errorf("got %q, want %q", got, original)
+ }
+}
+
+func TestGoStringEmpty(t *testing.T) {
+ cs := CString("")
+ defer FreeString(cs)
+ got := GoString(cs)
+ if got != "" {
+ t.Errorf("got %q, want empty string", got)
+ }
+}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.