Skip to content

Commit

Permalink
Use io package constants in seek function
Browse files Browse the repository at this point in the history
  • Loading branch information
cornelk committed Jun 18, 2024
1 parent e231891 commit 6d7538d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions buf_write_seeker.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package rosbag

import (
"io"
)

type bufWriteSeeker struct {
buf []byte
pos int
Expand All @@ -24,11 +28,11 @@ func (b *bufWriteSeeker) Write(p []byte) (int, error) {
// Seek implements io.Seeker.
func (b *bufWriteSeeker) Seek(offset int64, whence int) (int64, error) {
switch whence {
case 0:
case io.SeekStart:
b.pos = int(offset)
case 1:
case io.SeekCurrent:
b.pos += int(offset)
case 2:
case io.SeekEnd:
b.pos = len(b.buf) + int(offset)
}
return int64(b.pos), nil
Expand Down

0 comments on commit 6d7538d

Please sign in to comment.