Consistent puncutation, names and constants

* European sentence punctuation, consistent with package docs
  * Match os.SEEK_* constants instead of numeric constants from io.Seeker
  * Consistent (shorter) receiver name for quickcheck value
This commit is contained in:
Sean Treadway 2014-06-13 10:22:04 +02:00
parent 68aec0278e
commit b5d9767c0a
2 changed files with 18 additions and 24 deletions

View File

@ -634,21 +634,15 @@ func (f *File) Write(b []byte) (int, error) {
}
// Seek implements io.Seeker by setting the client offset for the next Read or
// Write. It returns the next offset read. Seeking before of after the end of
// Write. It returns the next offset read. Seeking before or after the end of
// the file is undefined. Seeking relative to the end calls Stat.
func (f *File) Seek(offset int64, whence int) (int64, error) {
const (
SET = 0
CUR = 1
END = 2
)
switch whence {
case SET:
case os.SEEK_SET:
f.offset = uint64(offset)
case CUR:
case os.SEEK_CUR:
f.offset = uint64(int64(f.offset) + offset)
case END:
case os.SEEK_END:
fi, err := f.Stat()
if err != nil {
return int64(f.offset), err

View File

@ -149,31 +149,31 @@ func (s seek) Generate(r *rand.Rand, _ int) reflect.Value {
return reflect.ValueOf(s)
}
func (cfg seek) set(t *testing.T, r io.ReadSeeker) {
if _, err := r.Seek(cfg.offset, 0); err != nil {
t.Fatalf("error while seeking with %+v: %v", cfg, err)
func (s seek) set(t *testing.T, r io.ReadSeeker) {
if _, err := r.Seek(s.offset, os.SEEK_SET); err != nil {
t.Fatalf("error while seeking with %+v: %v", s, err)
}
}
func (cfg seek) current(t *testing.T, r io.ReadSeeker) {
func (s seek) current(t *testing.T, r io.ReadSeeker) {
const mid = seekBytes / 2
skip := cfg.offset / 2
if cfg.offset > mid {
skip := s.offset / 2
if s.offset > mid {
skip = -skip
}
if _, err := r.Seek(mid, 0); err != nil {
t.Fatalf("error seeking to midpoint with %+v: %v", cfg, err)
if _, err := r.Seek(mid, os.SEEK_SET); err != nil {
t.Fatalf("error seeking to midpoint with %+v: %v", s, err)
}
if _, err := r.Seek(skip, 1); err != nil {
t.Fatalf("error seeking from %d with %+v: %v", mid, cfg, err)
if _, err := r.Seek(skip, os.SEEK_CUR); err != nil {
t.Fatalf("error seeking from %d with %+v: %v", mid, s, err)
}
}
func (cfg seek) end(t *testing.T, r io.ReadSeeker) {
if _, err := r.Seek(-cfg.offset, 2); err != nil {
t.Fatalf("error seeking from end with %+v: %v", cfg, err)
func (s seek) end(t *testing.T, r io.ReadSeeker) {
if _, err := r.Seek(-s.offset, os.SEEK_END); err != nil {
t.Fatalf("error seeking from end with %+v: %v", s, err)
}
}