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

Use UNIX path on all OSs other than Windows and Plan9 #3

Merged
merged 2 commits into from
Oct 26, 2020

Conversation

RedL0tus
Copy link
Contributor

Previous settings will cause this library fail to build in other OSs including many BSD distributions (FreeBSD, OpenBSD, NetBSD, etc). I found this problem while trying to build it on my FreeBSD server.

Since /etc/hosts is a pretty standard path for finding hosts file, it should be safe enough to set /etc/hosts as the default path.

Previous settings will cause this library fail to build in other
OSs including BSD distributions (FreeBSD, OpenBSD, NetBSD, etc).

Since /etc/hosts is a pretty standard path for finding hosts file,
it should be OK to set /etc/hosts as default.

Signed-off-by: Kay Lin <i@v2bv.net>
@jaytaylor
Copy link
Owner

Hi @RedL0tus,

I think this is already fixed, but not 100% sure. If you agree, please feel free to close it. Otherwise I will appreciate if you help me understand what more is needed in this department.

Sorry for leaving this for months, I didn't intend for it to slip under the radar but somehow it did!

Best wishes always,
Jay

@RedL0tus
Copy link
Contributor Author

Hi, @jaytaylor

Hmmm on FreeBSD it should be okay now.

But I think it may still be better to just write !plan9 !windows there, because there are a lot more UNIX-like systems (like other BSD distributions or things like Solaris/Illumos/OpenIndiana) and most of them has /etc/hosts as the path to their hosts file (defined in the POSIX standard). I think it would be pretty safe to use /etc/hosts as the fallback option.

Sincerely,
Kay

@jaytaylor
Copy link
Owner

Got you, one question though~

The current hosts_path_unix.go contains:

// +build linux darwin freebsd netbsd openbsd

So it seems like already it won't trigger inclusion for windows or plan9, so maybe the change would effectively be a no-op at this point? Let me know what you think.

Cheers.

@RedL0tus
Copy link
Contributor Author

RedL0tus commented Oct 26, 2020

So it seems like already it won't trigger inclusion for windows or plan9, so maybe the change would effectively be a no-op at this point? Let me know what you think.

I mean, replace the whole line with // +build !plan9 !windows so anything other than Plan9&Windows will use /etc/hosts.

I just checked all of the systems supported by Golang, only Plan9, Windows and several other strange things (e.g. JS, NaCl, Android) are not POSIX-compliant.

Sincerely,
Kay

@jaytaylor
Copy link
Owner

Got you, I like it, will do.

Thank you!

@RedL0tus
Copy link
Contributor Author

Great, thank you as well!

@RedL0tus RedL0tus closed this Oct 26, 2020
@jaytaylor jaytaylor merged commit f581673 into jaytaylor:master Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants