-
Notifications
You must be signed in to change notification settings - Fork 50
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
add GetGoRoot #42
add GetGoRoot #42
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contributing. I think this is a great additional feature to the project.
I've provided some suggestions and before I can merge this I'd like to have some tests around this. The project uses a set of known golden files that can be used for tests. There are some helper functions to resolve the paths for the files. See TestGetTypes
for how they can be used. The CONTRIBUTING.md
doc explains how you can either download prebuilt binaries or build them yourself.
All the golden files should have a GOROOT of /usr/local/go
.
Hello, I have solved it according to the suggestion and added a test case to goroot_test.go, but the test case shows that the go version from 1.5 to 1.9 will not be recognized. I don’t know how to modify this part |
Can you take a look at how the string is addressed in the older versions? Strings are represented as: type str struct {
data ptr
len int
} In the logic for extracting the version string, it looks for a pointer to the beginning of this struct. After that I read either two uint32 or uint64 depending on word size used to get were the string starts and the length. It's possible that in older versions, the address and length are directly moved into the register without dereference it. That may be the issue. |
I have added the code to get goroot to support go versions between 1.5 and 1.9. It supports darwin and linux. Windows doesn’t seem to work because I didn’t find goroot string in the windows binary. |
It looks like the functionality you are using in the |
@TcM1911 I don't know how to make elegant test cases, can you help me? |
The variable switch test {
case "gold-windows-amd64-1.9.0":
case "gold-windows-386-1.9.0":
....
r.Equal(Err.., err)
default:
// The original part of the code
} Just add a small comment to note why the specific files are checked for an error... |
Thank you, I have updated it and now it works very well |
No description provided.