From c259675f29707ac3bf864b210b9c76d6adaefdc1 Mon Sep 17 00:00:00 2001 From: David Howden Date: Sun, 20 Sep 2015 20:13:12 +1000 Subject: [PATCH] Use switch in place of multiple if statements. --- sum.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sum.go b/sum.go index 1d9aa2e..2a3aa88 100644 --- a/sum.go +++ b/sum.go @@ -23,15 +23,14 @@ func Sum(r io.ReadSeeker) (string, error) { return "", fmt.Errorf("could not seek back to original position: %v", err) } - if string(b[0:4]) == "fLaC" { + switch { + case string(b[0:4]) == "fLaC": return SumFLAC(r) - } - if string(b[4:11]) == "ftypM4A" { + case string(b[4:11]) == "ftypM4A": return SumAtoms(r) - } - if string(b[0:3]) == "ID3" { + case string(b[0:3]) == "ID3": return SumID3v2(r) }