No description
- Go 100%
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. |
||
|---|---|---|
| docs | ||
| tests/cli/cgo | ||
| .woodpecker.yml | ||
| AGENTS.md | ||
| assert_test.go | ||
| buffer.go | ||
| buffer_example_test.go | ||
| buffer_test.go | ||
| call.go | ||
| call_example_test.go | ||
| call_test.go | ||
| call_test_support.go | ||
| CLAUDE.md | ||
| doc.go | ||
| go.mod | ||
| go.sum | ||
| README.md | ||
| scope.go | ||
| scope_example_test.go | ||
| scope_test.go | ||
| sonar-project.properties | ||
| string_conversion.go | ||
| string_conversion_example_test.go | ||
| string_conversion_test.go | ||
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:
Bufferowns C-backed byte memory and exposes it as a Go slice plus a raw pointer for C APIs.Scopegroups temporaryBufferand C string allocations so one cleanup call releases everything from a C interaction.CString,GoString,SizeT,Int,Errno, andWithErrnomake common C boundary conversions explicit.Callinvokes C function pointers with up to 18 pointer-sized arguments and maps non-zero return codes into failed CoreResults.
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.