After investigating the hasAltPkg mechanism, determined that it's not suitable for go/build.defaultContext() because: 1. hasAltPkg works well for providing additional/alternative functions 2. But defaultContext() needs to REPLACE an existing function that depends on internal/buildcfg, internal/goversion, and internal/platform 3. These internal packages cannot be imported from runtime/internal/lib The full overlay approach (2073 lines) works correctly. Seeking guidance on whether this is acceptable or if there's an alternative approach. Demo verified working: - runtime.Compiler = "llgo" - go/build.Import() works correctly - No "unknown compiler" error Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
38 lines
971 B
Go
38 lines
971 B
Go
package runtime
|
|
|
|
import (
|
|
_ "embed"
|
|
)
|
|
|
|
//go:embed _overlay/runtime/runtime.go
|
|
var fakeRuntime string
|
|
|
|
//go:embed _overlay/go/parser/resolver.go
|
|
var go_parser_resolver string
|
|
|
|
//go:embed _overlay/testing/testing.go
|
|
var testing_testing string
|
|
|
|
//go:embed _overlay/testing/testing_go123.go
|
|
var testing_testing_go123 string
|
|
|
|
//go:embed _overlay/testing/testing_go124.go
|
|
var testing_testing_go124 string
|
|
|
|
//go:embed _overlay/net/textproto/textproto.go
|
|
var net_textproto string
|
|
|
|
//go:embed _overlay/go/build/build.go
|
|
var go_build_build string
|
|
|
|
var OverlayFiles = map[string]string{
|
|
"math/exp_amd64.go": "package math;",
|
|
"go/parser/resolver.go": go_parser_resolver,
|
|
"go/build/build.go": go_build_build,
|
|
"testing/testing.go": testing_testing,
|
|
"testing/testing_go123.go": testing_testing_go123,
|
|
"testing/testing_go124.go": testing_testing_go124,
|
|
"net/textproto/textproto.go": net_textproto,
|
|
"runtime/runtime.go": fakeRuntime,
|
|
}
|