From 6d7538dcefdf8d9f980e03a52f99e2b5c59f4d2f Mon Sep 17 00:00:00 2001 From: cornelk Date: Tue, 18 Jun 2024 11:21:39 -0600 Subject: [PATCH] Use io package constants in seek function --- buf_write_seeker.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/buf_write_seeker.go b/buf_write_seeker.go index 8883b96..707fe83 100644 --- a/buf_write_seeker.go +++ b/buf_write_seeker.go @@ -1,5 +1,9 @@ package rosbag +import ( + "io" +) + type bufWriteSeeker struct { buf []byte pos int @@ -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