diff --git a/internal/plugin/package.go b/internal/plugin/package.go index 6be8ae3..1bdf297 100644 --- a/internal/plugin/package.go +++ b/internal/plugin/package.go @@ -519,6 +519,9 @@ func parseLocaleMessagesJSON(raw []byte) (map[string]string, error) { } func currentPlatformTag() string { + if override := strings.TrimSpace(os.Getenv("REIMS_GO_PLATFORM")); override != "" { + return strings.ToLower(strings.ReplaceAll(override, "/", "-")) + } arch := runtime.GOARCH if arch == "amd64" { arch = "x64" @@ -692,6 +695,12 @@ func matchesCurrentPlatform(platforms []string) bool { } curTag := currentPlatformTag() curPair := runtime.GOOS + "/" + runtime.GOARCH + if override := strings.TrimSpace(os.Getenv("REIMS_GO_PLATFORM")); override != "" { + curPair = strings.ToLower(strings.ReplaceAll(override, "-", "/")) + if curPair == "windows/x64" { + curPair = "windows/amd64" + } + } for _, p := range platforms { p = strings.TrimSpace(p) if p == "*" || strings.EqualFold(p, "any") || strings.EqualFold(p, curTag) || strings.EqualFold(p, curPair) { diff --git a/internal/plugin/platform_test.go b/internal/plugin/platform_test.go new file mode 100644 index 0000000..7bd0eb1 --- /dev/null +++ b/internal/plugin/platform_test.go @@ -0,0 +1,13 @@ +package plugin + +import "testing" + +func TestPlatformOverrideEnv(t *testing.T) { + t.Setenv("REIMS_GO_PLATFORM", "windows-x64") + if !matchesCurrentPlatform([]string{"windows-x64"}) || !matchesCurrentPlatform([]string{"windows/amd64"}) { + t.Fatal("expected windows-x64 override to match windows-x64 and windows/amd64") + } + if matchesCurrentPlatform([]string{"linux-x64"}) { + t.Fatal("expected windows-x64 override to reject linux-x64") + } +}