Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

common: changed if-else blocks to conform with golint #16656

Merged
merged 1 commit into from
May 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
common: changed if-else blocks to conform with golint
  • Loading branch information
GagziW committed May 2, 2018
commit 3c55955181ead3f1572d922b1e2453afb171a6cc
14 changes: 6 additions & 8 deletions common/bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,13 @@ func Hex2BytesFixed(str string, flen int) []byte {
h, _ := hex.DecodeString(str)
if len(h) == flen {
return h
} else {
if len(h) > flen {
return h[len(h)-flen:]
} else {
hh := make([]byte, flen)
copy(hh[flen-len(h):flen], h[:])
return hh
}
}
if len(h) > flen {
return h[len(h)-flen:]
}
hh := make([]byte, flen)
copy(hh[flen-len(h):flen], h[:])
return hh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would probably be cleaner as

switch {
    case len(h) == flen:
        // ...
    case len(h) > flen:
        // ...
    default:
        // ...
}

}

func RightPadBytes(slice []byte, l int) []byte {
Expand Down