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

cmd/go: add 'unix' build tag #6325

Closed
dominikh opened this issue Sep 4, 2013 · 3 comments
Closed

cmd/go: add 'unix' build tag #6325

dominikh opened this issue Sep 4, 2013 · 3 comments
Milestone

Comments

@dominikh
Copy link
Member

dominikh commented Sep 4, 2013

Would it make sense to add a 'unix' build tag? The Go standard library has 29 files
named *_unix.go¹, 22 of these interpret the tag as

"+build darwin dragonfly freebsd linux netbsd openbsd"

one also includes plan9, one also includes windows (which is somewhat unexpected), one
does not include dragonfly, one does not include openbsd or darwin, and one is defined
as "!windows,!plan9".

I primarily see two issues with the current situation:

1) When seeing a file named *_unix.go, it's not instantly obvious what platforms it
includes. As we can see, sometimes darwin is a Unix, sometimes it's not, and in one case
even Windows is a Unix.
2) When others emulate unix as it's used by Go, they'll have to update it when new
Unixes, like dragonfly, get added

Of course the inconsistencies mentioned in 1 are also a reason not to add a unix build
tag: Various files would need to be renamed or reorganized and it might conflict with
existing interpretations by users.

Is this possible to do in Go 1.x? Is there any merit to doing it?

¹: Determined with grep "+build" $GOROOT/src/**/*_unix.go
@ianlancetaylor
Copy link
Contributor

Comment 1:

Thanks, worth considering for 1.3.

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

Status changed to Accepted.

@bradfitz
Copy link
Contributor

bradfitz commented Sep 4, 2013

Comment 2:

Agreed. Also related are the foo_posix.go files:
./src/pkg/net/iprawsock_posix.go
./src/pkg/net/ipsock_posix.go
./src/pkg/net/sock_posix.go
./src/pkg/net/sockopt_posix.go
./src/pkg/net/sockoptip_posix.go
./src/pkg/net/tcpsock_posix.go
./src/pkg/net/tcpsockopt_posix.go
./src/pkg/net/udpsock_posix.go
./src/pkg/net/unixsock_posix.go
./src/pkg/os/exec_posix.go
./src/pkg/os/file_posix.go

@rsc
Copy link
Contributor

rsc commented Sep 5, 2013

Comment 3:

Is darwin unix? Is plan9 unix? Sometimes, but sometimes not.
I don't want to get into the business of defining what "unix" is.
Don't read too much into the file extension and let the +build lines speak for
themselves.

Status changed to WorkingAsIntended.

@rsc rsc added this to the Go1.3 milestone Apr 14, 2015
@rsc rsc removed the go1.3 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

5 participants