-
-
Notifications
You must be signed in to change notification settings - Fork 121
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 generate-package-code #167
Conversation
Codecov Report
@@ Coverage Diff @@
## master #167 +/- ##
=======================================
Coverage 81.72% 81.72%
=======================================
Files 8 8
Lines 1882 1882
=======================================
Hits 1538 1538
Misses 257 257
Partials 87 87 Continue to review full report at Codecov.
|
At present, we only take |
No, I mean maybe these standard packages can be done by generating code, because each package may have updates, and it is considered difficult to detect and update the code. |
I now see what this is doing, very cool. The concept is great. :) I am not sure if it will work in all cases. In particular, packages that have new methods adding to them, like sort as an example. There is a sort 1.8 build. Also note that some packages have appengine build constraints/tags. It should at least be able to use as a good starting template for checking what we have or adding new packages. |
It is difficult to create a portable package file using this tool. Because syscall has different methods depending on OS. So I think that it must have a dictionary or whitelist. |
can use makefile to make only specific packages use the generated code |
Might be better for how it is now to remove the makefile and just run it manually as wanted. Great tool, can do lots with it, just not full automatic. |
@chyroc |
I have resolved the conflict, but there are still some problems. Columns such as
are a type(but is not a struct) or a var or interface, so they cannot use |
time.Nanosecond is already added: |
I think something like this will work: Also can check out Signal: |
Note that the build tests are failing because json.Valid was not added until go 1.9 |
@chyroc |
I noticed, I will fix him, I'm sorry to be busy recently |
I have a problem: The type of import is now through:
Whether to continue this way, or unified as the second way |
interface can be nil. For example, This is typed nil.
|
A note, I think this code should try to handle all the cases. This code is great for generating a template that can be updated by hand. |
how to deal with |
40b4b97
to
56a5ee5
Compare
Should be able to just convert it to a uint64. |
Have you read up on Build Constraints? https://golang.org/pkg/go/build/ Looks like there are extra Build Constraints that are not wanted. For example: // +build go1.8,!go1.10 Which means build if (1.8 or greater) OR (not 1.10 or great), which probably not what we are going for. |
Also there is the custom build tag appengine which I believe is used to create the engine for the web site. So |
packages/errors.go
Outdated
@@ -8,4 +8,6 @@ func init() { | |||
Packages["errors"] = map[string]interface{}{ | |||
"New": errors.New, | |||
} | |||
PackageTypes["errors"] = map[string]interface{}{} |
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.
Empty PackageTypes can be removed.
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.
done.
packages/math.110.go
Outdated
func init_math() { | ||
|
||
Packages["math"]["Erfcinv"] = math.Erfcinv | ||
|
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.
Not a big deal, but would be nice to remove the extra spaces.
packages/os.go
Outdated
"ErrExist": os.ErrExist, | ||
"ErrInvalid": os.ErrInvalid, | ||
"ErrNotExist": os.ErrNotExist, | ||
"ErrPermission": os.ErrPermission, | ||
"Executable": os.Executable, |
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.
Some of the added function should be added to // +build !appengine
like Executable, Unsetenv, and etc.
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.
Ok. Then just ask, how to know the list of // +build !appengine
packages/sort.go
Outdated
"Search": sort.Search, | ||
"SearchFloat64s": sort.SearchFloat64s, | ||
"SearchInts": sort.SearchInts, | ||
"SearchStrings": sort.SearchStrings, | ||
"Slice": sort.Slice, |
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.
Slice* should be added to // +build go1.8
Yes, I read ~ For example, the function Take the function |
Also, how are you checking what version each of the newly adding functions and types are in? |
Looking at json.Valid, that should be // +build go1.9 and the other file should be // +build !go1.9. |
Maybe we can run |
While we are only testing 1.8, 1.9, 1.10 in travis, still want to try to be compatible to lower versions when/if possible. That means trying to figure out which version functions and types were added, for all the newly added functions and types. |
Note #49 for overflows int issue. |
76a4572
to
f993ed4
Compare
Should we first create maps of all packages and then add functions or variables one by one.
This avoids the need to create two file builds similar to the appengine environment |
f993ed4
to
4f7d68f
Compare
We are adding functions or variables one at a time, don't think a lock is needed. Not seeing how this avoids the need for build files. If you want to have only have two appengine build files, can have those files sets a flag, then use that flag to set the data. |
a87070e
to
9bd7bd3
Compare
9bd7bd3
to
efaebbe
Compare
run such code to generate code: #!/bin/bash
mkdir go && cd go
for i in 1.6.4 1.7.6 1.8.7 1.9.6 1.10.3
do
echo "download go $i ing."
wget https://dl.google.com/go/go$i.linux-amd64.tar.gz && tar zxvf go$i.linux-amd64.tar.gz && mv go $i
rm go$i.linux-amd64.tar.gz
echo "done."
done
cd ..
find packages | grep -vE '_test|Engine' | grep '/' | xargs rm
go run cmd/generate-std-packages/*.go -go16 ./go/1.6.4/bin/go -go17 ./go/1.7.6/bin/go -go18 ./go/1.8.7/bin/go -go19 ./go/1.9.6/bin/go -go110 ./1.10.3/bin/go && gofmt -s -w ./packages/*
|
@MichaelS11 @mattn please see again, thank you. |
I leave this to @mattn I was fine with the simple starting template and making changes by hand. |
I don't have strong opnion, Is it possible to make composite literal like?
|
should i add |
No description provided.