Skip to content

Commit 5e4a52b

Browse files
committed
fix goreportcard problems
1 parent c07fc54 commit 5e4a52b

File tree

6 files changed

+25
-28
lines changed

6 files changed

+25
-28
lines changed

compositors.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package beep
22

33
// Take returns a Streamer which streams at most num samples from s.
44
//
5-
// The returned Streamer propagates s's errors throught Err.
5+
// The returned Streamer propagates s's errors through Err.
66
func Take(num int, s Streamer) Streamer {
77
return &take{
88
s: s,
@@ -94,7 +94,7 @@ func Seq(s ...Streamer) Streamer {
9494
})
9595
}
9696

97-
// Mix takes zero or more Streamers and returns a Streamer which streames them mixed together.
97+
// Mix takes zero or more Streamers and returns a Streamer which streams them mixed together.
9898
//
9999
// Mix does not propagate errors from the Streamers.
100100
func Mix(s ...Streamer) Streamer {

effects/mono.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "github.com/faiface/beep"
55
// Mono converts the wrapped Streamer to a mono buffer
66
// by downmixing the left and right channels together.
77
//
8-
// The returned Streamer propagates s's errors throught Err.
8+
// The returned Streamer propagates s's errors through Err.
99
func Mono(s beep.Streamer) beep.Streamer {
1010
return &mono{s}
1111
}

effects/swap.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import "github.com/faiface/beep"
44

55
// Swap swaps the left and right channel of the wrapped Streamer.
66
//
7-
// The returned Streamer propagates s's errors throught Err.
7+
// The returned Streamer propagates s's errors through Err.
88
func Swap(s beep.Streamer) beep.Streamer {
99
return &swap{s}
1010
}

flac/decode.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
// StreamSeekCloser when you want to release the resources.
1717
func Decode(rc io.ReadCloser) (s beep.StreamSeekCloser, format beep.Format, err error) {
1818
d := decoder{rc: rc}
19-
defer func() { // hacky way to always close rc if an error occured
19+
defer func() { // hacky way to always close rc if an error occurred
2020
if err != nil {
2121
d.rc.Close()
2222
}

interface.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type Streamer interface {
3232
// this case is valid. Only this case may occur in the following calls.
3333
Stream(samples [][2]float64) (n int, ok bool)
3434

35-
// Err returns an error which occured during streaming. If no error occured, nil is
35+
// Err returns an error which occurred during streaming. If no error occurred, nil is
3636
// returned.
3737
//
3838
// When an error occurs, Streamer must become drained and Stream must return 0, false

wav/decode.go

+19-22
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
// StreamSeekCloser when you want to release the resources.
1919
func Decode(rc io.ReadCloser) (s beep.StreamSeekCloser, format beep.Format, err error) {
2020
d := decoder{rc: rc}
21-
defer func() { // hacky way to always close rsc if an error occured
21+
defer func() { // hacky way to always close rsc if an error occurred
2222
if err != nil {
2323
d.rc.Close()
2424
}
@@ -29,7 +29,7 @@ func Decode(rc io.ReadCloser) (s beep.StreamSeekCloser, format beep.Format, err
2929
return nil, beep.Format{}, errors.Wrap(err, "wav")
3030
}
3131
if string(d.h.RiffMark[:]) != "RIFF" {
32-
return nil, beep.Format{}, errors.New(fmt.Sprintf("wav: missing RIFF at the beginning > %s", string(d.h.RiffMark[:])))
32+
return nil, beep.Format{}, fmt.Errorf("wav: missing RIFF at the beginning > %s", string(d.h.RiffMark[:]))
3333
}
3434

3535
// READ Total file size
@@ -45,7 +45,7 @@ func Decode(rc io.ReadCloser) (s beep.StreamSeekCloser, format beep.Format, err
4545

4646
// check each formtypes
4747
ft := [4]byte{0, 0, 0, 0}
48-
var fs int32 = 0
48+
var fs int32
4949
d.hsz = 4 + 4 + 4 // add size of (RiffMark + FileSize + WaveMark)
5050
for string(ft[:]) != "data" {
5151
if err = binary.Read(rc, binary.LittleEndian, ft[:]); err != nil {
@@ -69,13 +69,12 @@ func Decode(rc io.ReadCloser) (s beep.StreamSeekCloser, format beep.Format, err
6969
}
7070
if err := binary.Read(rc, binary.LittleEndian, &fmtchunk); err != nil {
7171
return nil, beep.Format{}, errors.New("wav: missing format chunk body")
72-
} else {
73-
d.h.NumChans = fmtchunk.NumChans
74-
d.h.SampleRate = fmtchunk.SampleRate
75-
d.h.ByteRate = fmtchunk.ByteRate
76-
d.h.BytesPerFrame = fmtchunk.BytesPerFrame
77-
d.h.BitsPerSample = fmtchunk.BitsPerSample
7872
}
73+
d.h.NumChans = fmtchunk.NumChans
74+
d.h.SampleRate = fmtchunk.SampleRate
75+
d.h.ByteRate = fmtchunk.ByteRate
76+
d.h.BytesPerFrame = fmtchunk.BytesPerFrame
77+
d.h.BitsPerSample = fmtchunk.BitsPerSample
7978

8079
// SubFormat is represented by GUID. Plain PCM is KSDATAFORMAT_SUBTYPE_PCM GUID.
8180
// See https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/ksmedia/ns-ksmedia-waveformatextensible
@@ -84,26 +83,24 @@ func Decode(rc io.ReadCloser) (s beep.StreamSeekCloser, format beep.Format, err
8483
[8]byte{0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71},
8584
}
8685
if fmtchunk.SubFormat != pcmguid {
87-
return nil, beep.Format{}, errors.New(
88-
fmt.Sprintf(
89-
"wav: unsupported sub format type - %08x-%04x-%04x-%s",
90-
fmtchunk.SubFormat.Data1, fmtchunk.SubFormat.Data2, fmtchunk.SubFormat.Data3,
91-
hex.EncodeToString(fmtchunk.SubFormat.Data4[:]),
92-
),
86+
return nil, beep.Format{}, fmt.Errorf(
87+
"wav: unsupported sub format type - %08x-%04x-%04x-%s",
88+
fmtchunk.SubFormat.Data1, fmtchunk.SubFormat.Data2, fmtchunk.SubFormat.Data3,
89+
hex.EncodeToString(fmtchunk.SubFormat.Data4[:]),
9390
)
9491
}
9592
} else {
9693
// WAVEFORMAT or WAVEFORMATEX
9794
fmtchunk := formatchunk{0, 0, 0, 0, 0}
9895
if err := binary.Read(rc, binary.LittleEndian, &fmtchunk); err != nil {
9996
return nil, beep.Format{}, errors.New("wav: missing format chunk body")
100-
} else {
101-
d.h.NumChans = fmtchunk.NumChans
102-
d.h.SampleRate = fmtchunk.SampleRate
103-
d.h.ByteRate = fmtchunk.ByteRate
104-
d.h.BytesPerFrame = fmtchunk.BytesPerFrame
105-
d.h.BitsPerSample = fmtchunk.BitsPerSample
10697
}
98+
d.h.NumChans = fmtchunk.NumChans
99+
d.h.SampleRate = fmtchunk.SampleRate
100+
d.h.ByteRate = fmtchunk.ByteRate
101+
d.h.BytesPerFrame = fmtchunk.BytesPerFrame
102+
d.h.BitsPerSample = fmtchunk.BitsPerSample
103+
107104
// it would be skipping cbSize (WAVEFORMATEX's last member).
108105
if d.h.FormatSize > 16 {
109106
trash := make([]byte, d.h.FormatSize-16)
@@ -137,7 +134,7 @@ func Decode(rc io.ReadCloser) (s beep.StreamSeekCloser, format beep.Format, err
137134
return nil, beep.Format{}, errors.New("wav: missing data chunk marker")
138135
}
139136
if d.h.FormatType != 1 && d.h.FormatType != -2 {
140-
return nil, beep.Format{}, errors.New(fmt.Sprintf("wav: unsupported format type - %d", d.h.FormatType))
137+
return nil, beep.Format{}, fmt.Errorf("wav: unsupported format type - %d", d.h.FormatType)
141138
}
142139
if d.h.NumChans <= 0 {
143140
return nil, beep.Format{}, errors.New("wav: invalid number of channels (less than 1)")

0 commit comments

Comments
 (0)