Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.

Commit b215ef5

Browse files
committed
fix some platform flag bugs, tested
1 parent d99dbdb commit b215ef5

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

platform_flag.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,19 @@ func (p *PlatformFlag) Platforms(supported []Platform) []Platform {
8787
})
8888
}
8989
}
90+
} else if len(includeOS) > 0 {
91+
// Build up the list of prefiltered by what is specified
92+
if prefilter == nil {
93+
prefilter = make([]Platform, 0, len(p.Arch)*len(p.OS))
94+
}
95+
96+
for _, os := range p.OS {
97+
for _, platform := range supported {
98+
if platform.OS == os {
99+
prefilter = append(prefilter, platform)
100+
}
101+
}
102+
}
90103
}
91104

92105
if prefilter != nil {

platform_flag_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,21 @@ func TestPlatformFlagPlatforms(t *testing.T) {
160160
},
161161

162162
// Adds non-default by OS
163+
{
164+
[]string{"bar"},
165+
[]string{},
166+
[]Platform{},
167+
[]Platform{
168+
{"foo", "bar", true},
169+
{"foo", "baz", true},
170+
{"bar", "bar", false},
171+
},
172+
[]Platform{
173+
{"bar", "bar", false},
174+
},
175+
},
176+
177+
// Adds non-default by both
163178
{
164179
[]string{"bar"},
165180
[]string{"bar"},

0 commit comments

Comments
 (0)