fix(go): 修复关闭 CGO 时的 Transform 悬空引用#3
Closed
wuchulonly wants to merge 1 commit into
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
新版 Go FFI 已移除旧的无操作 stub,Graph、CAS、Parse 和 Transform 均依赖 CGO。关闭 CGO 时,包含
import "C"的文件会被 Go 自动排除,但transform.go仍参与编译并引用已被排除的原生Transform实现,最终出现undefined: Transform。修改内容
go/transform.go增加//go:build cgo,避免 CGO 关闭时留下悬空原生符号。go/graph_test.go增加相同构建约束,明确 Graph 测试属于原生能力。CGO_ENABLED=0检查,保证生成的 SCO/SRO 数据类型和 JSON helper 可以独立编译。CGO_ENABLED=1原生回归测试,覆盖完整 FFI 能力。验证结果
CGO_ENABLED=0 go test ./...通过。CGO_ENABLED=1 go test ./...通过。git diff --check通过。兼容性说明
本修改不会恢复旧的静默 stub。需要 Graph、CAS、Parse 或 Transform 的调用方仍必须使用
CGO_ENABLED=1;CGO 关闭时只保留类型定义和 JSON 相关能力。