cleanup: All conditionals simplified under pkg. (#3875)

Address all the changes reported/recommended by
`gosimple` tool.
This commit is contained in:
Harshavardhana 2017-03-09 10:13:30 -08:00 committed by GitHub
parent 43317530d5
commit 85cbd875fc
5 changed files with 8 additions and 21 deletions

View File

@ -40,7 +40,7 @@ var fsType2StringMap = map[string]string{
func getFSType(ftype int64) string {
fsTypeHex := strconv.FormatInt(ftype, 16)
fsTypeString, ok := fsType2StringMap[fsTypeHex]
if ok == false {
if !ok {
return "UNKNOWN"
}
return fsTypeString

View File

@ -1,5 +1,5 @@
/*
* Minio Cloud Storage, (C) 2016 Minio, Inc.
* 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.
@ -276,14 +276,9 @@ func (c AdminClient) dumpHTTP(req *http.Request, resp *http.Response) error {
// Ends the http dump.
_, err = fmt.Fprintln(c.traceOutput, "---------END-HTTP---------")
if err != nil {
return err
}
// Returns success.
return nil
}
// do - execute http request.
func (c AdminClient) do(req *http.Request) (*http.Response, error) {
var resp *http.Response

View File

@ -211,11 +211,8 @@ func (adm *AdminClient) listObjectsHeal(bucket, prefix, marker, delimiter string
}
err = xml.NewDecoder(resp.Body).Decode(&toBeHealedObjects)
if err != nil {
return toBeHealedObjects, err
}
return toBeHealedObjects, nil
}
// ListObjectsHeal - Lists upto maxKeys objects that needing heal matching bucket, prefix, marker, delimiter.
func (adm *AdminClient) ListObjectsHeal(bucket, prefix string, recursive bool, doneCh <-chan struct{}) (<-chan ObjectInfo, error) {

View File

@ -1,5 +1,5 @@
/*
* mime-db: Mime Database, (C) 2015, 2016 Minio, Inc.
* mime-db: Mime Database, (C) 2015, 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.
@ -25,7 +25,7 @@ func TestMimeLookup(t *testing.T) {
t.Fatalf("Invalid content type are found expected \"application/x-msdownload\", got %s", contentType)
}
compressible := DB["txt"].Compressible
if compressible != false {
if compressible {
t.Fatalf("Invalid content type are found expected \"false\", got %t", compressible)
}
}

View File

@ -122,8 +122,7 @@ func saveFileConfig(filename string, v interface{}) error {
// decoder format according to the filename extension. If no
// extension is provided, json will be selected by default.
func loadFileConfig(filename string, v interface{}) error {
_, err := os.Stat(filename)
if err != nil {
if _, err := os.Stat(filename); err != nil {
return err
}
fileData, err := ioutil.ReadFile(filename)
@ -133,10 +132,6 @@ func loadFileConfig(filename string, v interface{}) error {
if runtime.GOOS == "windows" {
fileData = []byte(strings.Replace(string(fileData), "\r\n", "\n", -1))
}
ext := filepath.Ext(filename)
// Unmarshal file's content
if err := toUnmarshaller(ext)(fileData, v); err != nil {
return err
}
return nil
return toUnmarshaller(filepath.Ext(filename))(fileData, v)
}