Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io: duplicate seek whence value consts here? #6873

Closed
gopherbot opened this issue Dec 2, 2013 · 3 comments
Closed

io: duplicate seek whence value consts here? #6873

gopherbot opened this issue Dec 2, 2013 · 3 comments
Milestone

Comments

@gopherbot
Copy link

by fuzxxl:

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.
@minux
Copy link
Member

minux commented Dec 2, 2013

Comment 1:

Labels changed: added priority-later, removed priority-triage.

@minux
Copy link
Member

minux commented Dec 3, 2013

Comment 2:

please see discussion here: https://golang.org/cl/36810043/

Status changed to WontFix.

@robpike
Copy link
Contributor

robpike commented Dec 17, 2013

Comment 3:

Issue #6978 has been merged into this issue.

@rsc rsc added this to the Go1.3 milestone Apr 14, 2015
@rsc rsc removed the go1.3maybe label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants