No description
Find a file
Snider fa22f9f5a5 chore(sonar): address all 4 code smells (5.5 lane)
Per-rule fixes:
- S1192 (string-literal dup): 2
- S4144 (identical implementations): 1
- yaml:DocumentStartCheck: 1

Also drops go.work (workspace file moved out — pre-existing deletion
from working tree, not introduced by this lane).

vet/test/golangci-lint clean. v0.9.0 audit COMPLIANT.
2026-04-30 14:26:14 +01:00
docs refactor(core): align go-cgo with hardened core/go reference shape 2026-04-29 05:26:06 +01:00
tests/cli/cgo chore(sonar): address all 4 code smells (5.5 lane) 2026-04-30 14:26:14 +01:00
.woodpecker.yml ci: woodpecker pipeline (Go) — golangci-lint/eslint/phpstan + sonar.lthn.sh 2026-04-29 00:03:01 +01:00
AGENTS.md refactor(core): align go-cgo with hardened core/go reference shape 2026-04-29 05:26:06 +01:00
assert_test.go refactor(core): full v0.9.0 compliance against core/go reference 2026-04-28 18:32:35 +01:00
buffer.go refactor(core): align go-cgo with hardened core/go reference shape 2026-04-29 05:26:06 +01:00
buffer_example_test.go refactor(core): align go-cgo with hardened core/go reference shape 2026-04-29 05:26:06 +01:00
buffer_test.go chore(sonar): address all 4 code smells (5.5 lane) 2026-04-30 14:26:14 +01:00
call.go refactor(core): align go-cgo with hardened core/go reference shape 2026-04-29 05:26:06 +01:00
call_example_test.go docs(core): canonical CoreGO consumer docs + Example* coverage 2026-04-29 02:17:33 +01:00
call_test.go refactor(core): align go-cgo with hardened core/go reference shape 2026-04-29 05:26:06 +01:00
call_test_support.go refactor(core): align go-cgo with hardened core/go reference shape 2026-04-29 05:26:06 +01:00
CLAUDE.md docs(core): canonical CoreGO consumer docs + Example* coverage 2026-04-29 02:17:33 +01:00
doc.go Implement cgo harness APIs 2026-04-15 10:12:12 +01:00
go.mod refactor(core): full v0.9.0 compliance against core/go reference 2026-04-28 18:32:35 +01:00
go.sum refactor(core): full v0.9.0 compliance against core/go reference 2026-04-28 18:32:35 +01:00
README.md refactor(core): align go-cgo with hardened core/go reference shape 2026-04-29 05:26:06 +01:00
scope.go refactor(core): align go-cgo with hardened core/go reference shape 2026-04-29 05:26:06 +01:00
scope_example_test.go refactor(core): align go-cgo with hardened core/go reference shape 2026-04-29 05:26:06 +01:00
scope_test.go refactor(core): align go-cgo with hardened core/go reference shape 2026-04-29 05:26:06 +01:00
sonar-project.properties ci: woodpecker pipeline (Go) — golangci-lint/eslint/phpstan + sonar.lthn.sh 2026-04-28 23:33:17 +01:00
string_conversion.go refactor(core): align go-cgo with hardened core/go reference shape 2026-04-29 05:26:06 +01:00
string_conversion_example_test.go chore(sonar): address all 4 code smells (5.5 lane) 2026-04-30 14:26:14 +01:00
string_conversion_test.go refactor(core): align go-cgo with hardened core/go reference shape 2026-04-29 05:26:06 +01:00

go-cgo

dappco.re/go/cgo is the Core cgo utility package. It provides the small set of allocation, conversion, and function-pointer helpers that Core packages use when they need to cross from Go into C without repeating ownership boilerplate.

The package focuses on four jobs:

  • Buffer owns C-backed byte memory and exposes it as a Go slice plus a raw pointer for C APIs.
  • Scope groups temporary Buffer and C string allocations so one cleanup call releases everything from a C interaction.
  • CString, GoString, SizeT, Int, Errno, and WithErrno make common C boundary conversions explicit.
  • Call invokes C function pointers with up to 18 pointer-sized arguments and maps non-zero return codes into failed Core Results.

Install

go get dappco.re/go/cgo

The package uses cgo, so local builds need a working C toolchain and CGO_ENABLED=1.

Quick Start

package main

import (
	"unsafe"

	core "dappco.re/go"
	corecgo "dappco.re/go/cgo"
)

func main() {
	scope := corecgo.NewScope()
	defer scope.FreeAll()

	input := scope.Buffer(5)
	input.CopyFrom([]byte("hello"))

	cString := corecgo.CString("core")
	defer corecgo.Free(unsafe.Pointer(cString))

	core.Println(input.Len())
	core.Println(corecgo.GoString(cString))
}

Use Scope for temporary values owned by a single call path. Use standalone NewBuffer, CString, and Free when a value must outlive a local scope or be managed by a higher-level owner.

Verification

Before committing changes, run the same compliance gate used by this repository:

GOWORK=off go mod tidy
GOWORK=off go vet ./...
GOWORK=off go test -count=1 ./...
gofmt -l .
bash /Users/snider/Code/core/go/tests/cli/v090-upgrade/audit.sh .

The audit must finish with verdict: COMPLIANT.