-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
os: Hostname() truncate hostname more than 15 characters under Windows #9982
Comments
/cc @alexbrainman |
os.Hostname() / syscall.ComputerName() call GetComputerName() https://msdn.microsoft.com/ja-jp/library/windows/desktop/ms724295%28v=vs.85%29.aspx https://github.com/golang/go/blob/master/src/syscall/ztypes_windows.go#L144 And MAX_COMPUTERNAME_LENGTH is defined as 15 in mingw header. We should use GetComputerNameEx instead. https://msdn.microsoft.com/ja-jp/library/windows/desktop/ms724301(v=vs.85).aspx |
I have a CL that adds the *Ex equivalent functions to internal/syscall/windows (to not change syscall) but when I modify os.Hostname to use them instead, the bootstrap build of os fails because it can't import internal/syscall/windows for some reason. The regular build of os, and it's tests seem to run fine if the patch is applied to a previously compiled tree. |
You need to add internal/syscall/windows to the list of packages to be
built in cmd/dist/build.go.
|
@minux That fixed bootstrap, but:
|
I think we can fix the dep test in go/build by adding
internal/syscall/windows to the list (the internal package is effectively
the new syscall package, so its addition should be acceptable)
I don't think adding internal/syscall/windows to the bootstrap package list
will break bootstrap on non-windows systems.
|
@cookieo9 Did you add internal/... into https://github.com/golang/go/blob/master/src/go/build/deps_test.go#L126 ? |
Yup, its in the CL. https://go-review.googlesource.com/#/c/5852/ |
@kartlee please check if https://go-review.googlesource.com/#/c/5852 does fixes your issue. Thank you. |
@alexbrainman This works great...Thanks for quickly addressing it. -Karthik |
@cookieo9 fix it. Thank him. Alex |
@cookieo9 Thanks for the fix. |
@kartlee I also added new hostname test on windows https://go-review.googlesource.com/6070 Can you, please, update your source and try the test on pdx-srv2012-wv01 ? I am interested if test fail - see what your hostname command says. Thank you. Alex |
@alexbrainman Sorry for not getting back earlier. I will run them today and update the ticket. BTW, we are still using go 1.2 and doesn't want to upgrade for our current product release, so I just applied the code upstream into our custom package's Hostname() and added a similar nightly build test to inform when the result between os.Hostname(..) and custom package's Hostname(..) match for machine name greater than 15 characters. This will help us to move to your change with go 1.5. |
Thank you for confirming. |
Hi Folks,
One of our virtual machine name is pdx-srv2012-wv01. And os.Hostname(..) return hostname as pdx-srv2013-wv0 in this case. The native hostname.exe of windows from sysinternals return the right hostname. It looks like the implementation in GO seem to use GetComputerName(..) instead of GetComputerNameEx(..) to return the NetBIOS name. Is there any reason for it? Can we change this to return the dns hostname as NetBIOS seem to be getting old with later version of windows?
The version of GO I am using is 1.3.
-Karthik
The text was updated successfully, but these errors were encountered: