You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, the package io specifies the Seeker with its sole method Seek(). The
whence-parameter of Seek() is specified to accept one of the constants 1 to 3 with
certain semantics.
io does not provide symbolic constants for the whence-parameter, even there should
clearly be a set for clarity. os provides such constants though:
const (
SEEK_SET int = 0 // seek relative to the origin of the file
SEEK_CUR int = 1 // seek relative to the current offset
SEEK_END int = 2 // seek relative to the end
)
I think these constants are at the wrong place since if you want to use a generic
Seeker, you have to import os, a module with a concrete Seeker implementation, if you
want to use symbolic constants for the whence parameter. This gives people who have a
glance at your code the wrong idea that the source code they are looking at actually
communicates with the operating system which it might not do.
To fix this issue, I suggest duplicating the constants SEEK_SET, SEEK_CUR and SEEK_END
into the io module and suggesting people to use the symbolic constants from there
instead from os, as they semantically belong to io IMHO.
This change would only affect backwards-compatibility if somebody declared SEEK_SET,
SEEK_CUR and SEEK_END in their own source code while importing io without a qualifier,
but this is explicitly allowed by the compatibility rules.
The text was updated successfully, but these errors were encountered:
by fuzxxl:
The text was updated successfully, but these errors were encountered: