diff --git a/main.go b/main.go index 96f183942..3ddbe2a4f 100644 --- a/main.go +++ b/main.go @@ -1,5 +1,5 @@ /* - * Minio Cloud Storage, (C) 2016,2017 Minio, Inc. + * Minio Cloud Storage, (C) 2016, 2017, 2018 Minio, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,8 +54,7 @@ func checkGoVersion(goVersionStr string) error { } if !constraint.Check(goVersion) { - return fmt.Errorf("Minio is not compiled by Go %s. Please recompile accordingly", - goVersionConstraint) + return fmt.Errorf("Minio is not compiled by go %s. Minimum required version is %s, go %s release is known to have security issues. Please recompile accordingly", goVersionConstraint, minGoVersion, runtime.Version()[2:]) } return nil @@ -65,7 +64,7 @@ func main() { // When `go get` is used minimum Go version check is not triggered but it would have compiled it successfully. // However such binary will fail at runtime, hence we also check Go version at runtime. if err := checkGoVersion(runtime.Version()[2:]); err != nil { - console.Fatalln("Go runtime version check failed.", err) + console.Errorln(err) } minio.Main(os.Args) diff --git a/main_test.go b/main_test.go index 5a24bdc40..68a922463 100644 --- a/main_test.go +++ b/main_test.go @@ -1,5 +1,5 @@ /* - * Minio Cloud Storage, (C) 2017 Minio, Inc. + * Minio Cloud Storage, (C) 2017, 2018 Minio, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,34 +17,30 @@ package main import ( - "fmt" "testing" ) func TestCheckGoVersion(t *testing.T) { // Test success cases. testCases := []struct { - version string - expectedErr error + version string + success bool }{ - {minGoVersion, nil}, - {"1.6.8", fmt.Errorf("Minio is not compiled by Go >= 1.9.4. Please recompile accordingly")}, - {"1.5", fmt.Errorf("Minio is not compiled by Go >= 1.9.4. Please recompile accordingly")}, - {"0.1", fmt.Errorf("Minio is not compiled by Go >= 1.9.4. Please recompile accordingly")}, - {".1", fmt.Errorf("Malformed version: .1")}, - {"somejunk", fmt.Errorf("Malformed version: somejunk")}, + {minGoVersion, true}, + {"1.6.8", false}, + {"1.5", false}, + {"0.1", false}, + {".1", false}, + {"somejunk", false}, } for _, testCase := range testCases { err := checkGoVersion(testCase.version) - if testCase.expectedErr == nil { - if err != nil { - t.Fatalf("expected: %v, got: %v", testCase.expectedErr, err) - } - } else if err == nil { - t.Fatalf("expected: %v, got: %v", testCase.expectedErr, err) - } else if testCase.expectedErr.Error() != err.Error() { - t.Fatalf("expected: %v, got: %v", testCase.expectedErr, err) + if err != nil && testCase.success { + t.Fatalf("Test %v, expected: success, got: %v", testCase, err) + } + if err == nil && !testCase.success { + t.Fatalf("Test %v, expected: failure, got: success", testCase) } } }