Skip to content

Commit 3c57797

Browse files
authored
Merge pull request #1 from qbit/master
Default osSuffix to runtime.GOOS instead of calling panic()
2 parents 162f7fb + eb04472 commit 3c57797

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

properties.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,10 @@ var osSuffix string
9494

9595
func init() {
9696
switch value := runtime.GOOS; value {
97-
case "linux", "freebsd", "windows":
98-
osSuffix = runtime.GOOS
9997
case "darwin":
10098
osSuffix = "macosx"
10199
default:
102-
panic("Unsupported OS")
100+
osSuffix = runtime.GOOS
103101
}
104102
}
105103

properties_test.go

+5-11
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,14 @@ func TestPropertiesTestTxt(t *testing.T) {
5858
p, err := Load(filepath.Join("testdata", "test.txt"))
5959

6060
require.NoError(t, err)
61-
62-
require.Equal(t, 4, p.Size())
6361
require.Equal(t, "value = 1", p.Get("key"))
6462

65-
switch value := runtime.GOOS; value {
66-
case "linux":
67-
require.Equal(t, "is linux", p.Get("which.os"))
68-
case "windows":
69-
require.Equal(t, "is windows", p.Get("which.os"))
70-
case "darwin":
71-
require.Equal(t, "is macosx", p.Get("which.os"))
72-
default:
73-
require.FailNow(t, "unsupported OS")
63+
runOS := runtime.GOOS
64+
if runOS == "darwin" {
65+
runOS = "macosx"
7466
}
67+
68+
require.Equal(t, fmt.Sprintf("is %s", runOS), p.Get("which.os"))
7569
}
7670

7771
func TestExpandPropsInStringAndMissingCheck(t *testing.T) {

testdata/test.txt

+3
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ which.os=dunno
66
which.os.linux=is linux
77
which.os.macosx=is macosx
88
which.os.windows=is windows
9+
which.os.openbsd=is openbsd
10+
which.os.freebsd=is freebsd
11+
which.os.netbsd=is netbsd

0 commit comments

Comments
 (0)