Repository navigation
Expand file tree
/
Copy pathmain.go
More file actions
69 lines (58 loc) · 1.99 KB
/
Copy pathmain.go
File metadata and controls
69 lines (58 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
7DAD
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* Minio Cloud Storage, (C) 2016,2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Below main package has canonical imports for 'go get' and 'go build'
* to work with all other clones of github.com/minio/minio repository. For
* more information refer https://golang.org/doc/go1.4#canonicalimports
*/
package main // import "github.com/minio/minio"
import (
"fmt"
"os"
"runtime"
version "github.com/hashicorp/go-version"
"github.com/minio/mc/pkg/console"
minio "github.com/minio/minio/cmd"
)
const (
// Minio requires at least Go v1.7
minGoVersion = "1.7"
goVersionConstraint = ">= " + minGoVersion
)
// Check if this binary is compiled with at least minimum Go version.
func checkGoVersion(goVersionStr string) error {
constraint, err := version.NewConstraint(goVersionConstraint)
if err != nil {
return fmt.Errorf("'%s': %s", goVersionConstraint, err)
}
goVersion, err := version.NewVersion(goVersionStr)
if err != nil {
return err
}
if !constraint.Check(goVersion) {
return fmt.Errorf("Minio is not compiled by Go %s. Please recompile accordingly.",
goVersionConstraint)
}
return nil
}
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)
}
minio.Main(os.Args)
}