flipped-aurora/gin-vue-admin · error

不支持的目标架构: %s

Error message

不支持的目标架构: %s

What it means

normalizeBuildTarget validates the requested target architecture against cliBuildGOARCHAllowList. If goarch (explicit or defaulted from runtime.GOARCH) is not whitelisted, the cross-compilation is refused with this error. It complements the GOOS check and prevents `go build` from failing downstream on invalid GOARCH values.

Source

Thrown at server/plugin/ai/service/sys_cli_build.go:44

	cliBuildGOOSAllowList   = map[string]struct{}{"windows": {}, "linux": {}, "darwin": {}}
	cliBuildGOARCHAllowList = map[string]struct{}{"amd64": {}, "arm64": {}}
)

// normalizeBuildTarget 校验并归一化目标平台。空值回退到当前运行平台。
func normalizeBuildTarget(goos, goarch string) (string, string, error) {
	goos = strings.ToLower(strings.TrimSpace(goos))
	goarch = strings.ToLower(strings.TrimSpace(goarch))
	if goos == "" {
		goos = runtime.GOOS
	}
	if goarch == "" {
		goarch = runtime.GOARCH
	}
	if _, ok := cliBuildGOOSAllowList[goos]; !ok {
		return "", "", fmt.Errorf("不支持的目标系统: %s", goos)
	}
	if _, ok := cliBuildGOARCHAllowList[goarch]; !ok {
		return "", "", fmt.Errorf("不支持的目标架构: %s", goarch)
	}
	return goos, goarch, nil
}

// cliBinaryExt 返回目标平台对应的二进制后缀。
func cliBinaryExt(goos string) string {
	if goos == "windows" {
		return ".exe"
	}
	return ""
}

// BuildCliBinary 把指定 CLI 的 manifest 内嵌进 gva 源码副本,交叉编译出一个开箱即用的二进制。
func (s *cliService) BuildCliBinary(ctx context.Context, req autoReq.BuildSysCliBinaryRequest) (string, []byte, error) {
	goos, goarch, err := normalizeBuildTarget(req.GOOS, req.GOARCH)
	if err != nil {
		return "", nil, err
	}

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Use Go GOARCH vocabulary: amd64, arm64, etc., matching cliBuildGOARCHAllowList
  2. Leave goarch empty to default to the server's runtime.GOARCH if that is acceptable
  3. If a new arch is genuinely needed, add it to cliBuildGOARCHAllowList and test the CGO_ENABLED=0 cross build
  4. Normalize/validate arch input in the API layer before calling the build service

Example fix

// before
svc.BuildCliBinary(cli, manifest, "linux", "x86_64")
// after
svc.BuildCliBinary(cli, manifest, "linux", "amd64")
Defensive patterns

Strategy: validation

Validate before calling

var cliBuildGOARCHAllowList = map[string]bool{"amd64": true, "arm64": true}
if !cliBuildGOARCHAllowList[goarch] {
    return fmt.Errorf("unsupported GOARCH %q; allowed: amd64, arm64", goarch)
}

Type guard

func isSupportedGOARCH(goarch string) bool {
    return map[string]bool{"amd64": true, "arm64": true}[goarch]
}

Try / catch

goos, goarch, err := normalizeBuildTarget(inGoos, inGoarch)
if err != nil {
    return nil, fmt.Errorf("invalid build target: %w", err)
}

Prevention

When it happens

Trigger: Calling BuildCliBinary/BuildCliSkill with goarch like "386", "armv7", "x86_64" (wrong name; Go uses "amd64"), or an empty/typoed arch string, when the value is not in cliBuildGOARCHAllowList.

Common situations: Using x86 naming conventions (x86_64/i386) instead of Go names (amd64/386); requesting rarely-tested archs; frontend sending arch strings not normalized to Go's GOARCH vocabulary.

Related errors


AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31). Data as JSON: /api/errors/2b2d4fbe7132c7c1. Report an issue: GitHub.