While there may be better ways to express what this logic, for clarity, 
here is the change that golint is actually suggesting:
// Load returns the list of partition found and their properties.
func (l *LinuxLoader) Load() ([]*Properties, error) {
    //-
    ret := []*Properties{}

    if temp, err := runDf(); err != nil {
        return ret, err
    }
    ret = PropertiesList(ret).Append(PropertiesList(temp))
    //-
    if temp, err := runLsLabel(); err != nil {
        return ret, err
    } else {
        ret = PropertiesList(ret).Append(PropertiesList(temp))
    }
    //-
    if temp, err := runLsUsb(); err != nil {
        return ret, err
    } else {
        ret = PropertiesList(ret).Merge(PropertiesList(temp), "IsRemovable")
    }
    //-
    if temp, err := runMount(); err != nil {
        return ret, err
    } else {
        ret = PropertiesList(ret).Merge(PropertiesList(temp), "Label")
    }
    //-
    return ret, nil
}

The change is at line 9.



On Thursday, March 16, 2017 at 1:11:28 PM UTC-4, mhh...@gmail.com wrote:
>
> Hi,
>
> golint will report
>
> if block ends with a return statement, so drop this else and outdent its 
> block (move short variable declaration to its own line if necessary) 
> (golint)    
>
> for this code,
>
>
> // Load returns the list of partition found and their properties.
> func (l *LinuxLoader) Load() ([]*Properties, error) {
>     //-
>     ret := []*Properties{}
>
>     if temp, err := runDf(); err != nil {
>         return ret, err
>     } else {
>         ret = PropertiesList(ret).Append(PropertiesList(temp))
>     }
>     //-
>     if temp, err := runLsLabel(); err != nil {
>         return ret, err
>     } else {
>         ret = PropertiesList(ret).Append(PropertiesList(temp))
>     }
>     //-
>     if temp, err := runLsUsb(); err != nil {
>         return ret, err
>     } else {
>         ret = PropertiesList(ret).Merge(PropertiesList(temp), 
> "IsRemovable")
>     }
>     //-
>     if temp, err := runMount(); err != nil {
>         return ret, err
>     } else {
>         ret = PropertiesList(ret).Merge(PropertiesList(temp), "Label")
>     }
>     //-
>     return ret, nil
> }
>
> Does it mean i should nest those stmts and let it be 4 level deep ?
> Is it the reco ?
>
> Is there something wrong about early returns ?
>
> thanks
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to