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
Support Go1.12 #900
Support Go1.12 #900
Conversation
circle.yml
Outdated
- run: go tool vet *.go # Go package in root directory. | ||
- run: for d in */; do echo $d; done | grep -v tests/ | grep -v third_party/ | xargs go tool vet # All subdirectories except "tests", "third_party". | ||
- run: go vet *.go # Go package in root directory. | ||
- run: for d in */; do echo ./$d...; done | grep -v ./doc | grep -v ./test | grep -v ./node | xargs go vet # All subdirectories except "doc", "tests", "node*". |
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.
Please explain this change.
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.
go tool vet
is deprecated andgo vet
is the substitute. (Error)- It looked like
go vet
required the relative paths for local packages. I thought this line tries togo vet
against part of the local directories. Is that correct?
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.
This change makes sense to me, as @hajimehoshi described above.
A few questions/suggestions:
-
I suspect the
go tool vet *.go
line can be simplified even further to justgo vet
, orgo vet .
, to run vet on the Go package with the import pathgithub.com/gopherjs/gopherjs
. It was*.go
previously becausego tool vet
did not accept import paths, only files and directories. -
Does
doc
directory need to be skipped? It has just 2 .md files, so the import path pattern./doc/...
should not be matching any packages.
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.
go vet ./doc/...
fails with the exit code non-zero, and I thought I needed to avoid.
Would go vet ./...
work btw?
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.
hajimehoshi@Hajimes-MacBook-Pro ~/go/src/github.com/gopherjs/gopherjs
$ go vet ./doc/...
go: warning: "./doc/..." matched no packages
no packages to vet
hajimehoshi@Hajimes-MacBook-Pro ~/go/src/github.com/gopherjs/gopherjs
$ echo $?
1
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.
Would
go vet ./...
work btw?
I don't think it would, because the intention is to skip "tests" directory from being vetted.
kv = iter.last | ||
} else { | ||
// Compare the index and the size of the actual key set, and check if the iterator is already exhausted. | ||
if iter.i >= js.Global.Call("$keys", iter.m).Length() { |
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.
Calling $keys
again does not look right at first glance. Which bug is this supposed to fix?
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.
Value
tries to access mapiterkeys
at the second and later Next
call (code, and iter.keys
can be already not synced with $keys
by deleting keys in a loop.
On second thought, my fix might not work with the below code:
iter := ValueOf(m).MapRange()
for iter.Next() {
delete(m, iter.Key())
}
if len(m) != 0 {
panic("not reached")
}
Let me think...
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.
Fixed.
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!
circle.yml
Outdated
- run: go tool vet *.go # Go package in root directory. | ||
- run: for d in */; do echo $d; done | grep -v tests/ | grep -v third_party/ | xargs go tool vet # All subdirectories except "tests", "third_party". | ||
- run: go vet *.go # Go package in root directory. | ||
- run: for d in */; do echo ./$d...; done | grep -v ./doc | grep -v ./test | grep -v ./node | xargs go vet # All subdirectories except "doc", "tests", "node*". |
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.
go tool vet
is deprecated andgo vet
is the substitute. (Error)- It looked like
go vet
required the relative paths for local packages. I thought this line tries togo vet
against part of the local directories. Is that correct?
kv = iter.last | ||
} else { | ||
// Compare the index and the size of the actual key set, and check if the iterator is already exhausted. | ||
if iter.i >= js.Global.Call("$keys", iter.m).Length() { |
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.
Value
tries to access mapiterkeys
at the second and later Next
call (code, and iter.keys
can be already not synced with $keys
by deleting keys in a loop.
On second thought, my fix might not work with the below code:
iter := ValueOf(m).MapRange()
for iter.Next() {
delete(m, iter.Key())
}
if len(m) != 0 {
panic("not reached")
}
Let me think...
I found another problem: the test doesn't work well on macOS (e.g. |
In the current situation:
Now I'm investigating why the tests don't work on Darwin. EDIT: This was a syscall issue. Fixed! |
Did you install source-map-support module and syscall module? The ones mentioned at https://github.com/gopherjs/gopherjs#gopherjs-run-gopherjs-test. They used to be more optional but by now I think they're mandatory for some tests. |
No, but I think the cause was that the |
Now all the known issues have been solved. Please take another look. Thank you! |
Just adding some notes based on us applying roughly the same patch to myitcv#41:
$ diff -wu 1.11 1.12
--- 1.11 2019-03-08 18:46:10.181963351 +0000
+++ 1.12 2019-03-08 18:46:02.570274117 +0000
@@ -88,6 +88,8 @@
index/suffixarray
internal/bytealg
internal/cpu
+internal/fmtsort
+internal/goroot
internal/nettrace
internal/poll
internal/race
@@ -99,6 +101,27 @@
internal/testenv
internal/testlog
internal/trace
+internal/x/crypto/chacha20poly1305
+internal/x/crypto/cryptobyte
+internal/x/crypto/cryptobyte/asn1
+internal/x/crypto/curve25519
+internal/x/crypto/hkdf
+internal/x/crypto/internal/chacha20
+internal/x/crypto/poly1305
+internal/x/net/dns/dnsmessage
+internal/x/net/http/httpguts
+internal/x/net/http/httpproxy
+internal/x/net/http2/hpack
+internal/x/net/idna
+internal/x/net/internal/nettest
+internal/x/net/nettest
+internal/x/text/secure
+internal/x/text/secure/bidirule
+internal/x/text/transform
+internal/x/text/unicode
+internal/x/text/unicode/bidi
+internal/x/text/unicode/norm
+internal/xcoff
io
io/ioutil
log
@@ -143,6 +166,7 @@
runtime/cgo
runtime/debug
runtime/internal/atomic
+runtime/internal/math
runtime/internal/sys
runtime/pprof
runtime/pprof/internal/profile
@@ -167,22 +191,3 @@
unicode/utf16
unicode/utf8
unsafe
-vendor/golang_org/x/crypto/chacha20poly1305
-vendor/golang_org/x/crypto/cryptobyte
-vendor/golang_org/x/crypto/cryptobyte/asn1
-vendor/golang_org/x/crypto/curve25519
-vendor/golang_org/x/crypto/internal/chacha20
-vendor/golang_org/x/crypto/poly1305
-vendor/golang_org/x/net/dns/dnsmessage
-vendor/golang_org/x/net/http/httpguts
-vendor/golang_org/x/net/http/httpproxy
-vendor/golang_org/x/net/http2/hpack
-vendor/golang_org/x/net/idna
-vendor/golang_org/x/net/internal/nettest
-vendor/golang_org/x/net/nettest
-vendor/golang_org/x/text/secure
-vendor/golang_org/x/text/secure/bidirule
-vendor/golang_org/x/text/transform
-vendor/golang_org/x/text/unicode
-vendor/golang_org/x/text/unicode/bidi
-vendor/golang_org/x/text/unicode/norm |
@myitcv Thank you! For the above diff, the original master's circle.yml doesn't include a lot of tests like
Done. |
I'd suggest switching to the negation-based approach. We can even do that ahead of the Go 1.12 changes. It's a simple, easy to understand change that means we won't have to manually keep track of new packages. Packages like |
A blacklist instead of the current whitelist makes sense. |
.std_test_pkg_exclusions
Outdated
image/color/palette | ||
image/internal/imageutil | ||
internal/cpu | ||
internal/fmtsort |
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.
A better starting point for this blacklist is the list of packages that were not tested as part of the 1.11 cycle (hence why I suggested we could/should do that as part of a separate, simple PR).
That would then highlight that you're including internal/fmtsort
in this file, i.e. it would be an additional package we're ignoring for Go 1.12.
I still think we should understand why this package in particular is failing, because it's fundamental to the sorting changes in the fmt
package and other places:
Package fmtsort provides a general stable ordering mechanism for maps, on behalf of the fmt and text/template packages.
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.
Sure. As I merged your PR, I'll be investigating why internal/fmtsort
tests failed. I agree fmtsort
is so fundamental that we need to care.
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.
The root cause is that getting pointer values from a slice is now counterintuitive
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.
Ha, nice, my guess is that conversion an integer from a pointer (in reflect
?) causes this issue
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.
https://github.com/gopherjs/gopherjs/blob/master/compiler/expressions.go#L982 I think this is the culprit
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.
I made the tests pass with these fixes:
- For pointers and channels, the current GopherJS cannot treat them well for sorting. Skip this.
- GopherJS cannot treat nil key in a map well. Skip this.
Using a black list is a more effective mechanism for expressing those standard library packages we don't want to test because it means we don't need to manually check whether new standard library packages have been added that would otherwise need to be added to the white list. See the discussion in gopherjs#900 for more context.
So that we can then see the true diff that the Go 1.12 changes in gopherjs#900 will introduce.
…902) Using a black list is a more effective mechanism for expressing those standard library packages we don't want to test because it means we don't need to manually check whether new standard library packages have been added that would otherwise need to be added to the white list. See the discussion in #900 for more context.
So that we can then see the true diff that the Go 1.12 changes in gopherjs#900 will introduce.
So that we can then see the true diff that the Go 1.12 changes in #900 will introduce.
Friendly ping |
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 very much for working on this @hajimehoshi, you did a great job implementing support for Go 1.12!
I've reviewed this and did not find any issues or significant opportunities for improvement. I left a few comments about some minor things.
I've also tested it with various GopherJS programs on macOS and they all ran without problems. The generated file sizes have increased by about 5-7% (depending on which standard library packages are imported), which is unfortunate but within normal range of new Go releases.
@dmitshur Thank you for reviewing! I appreciate your careful work. Should we squash the commits, or not? My preference is to squash them, but I'd like to obey the policy of GopherJS. |
When you ask if we should squash the commits, can you clarify what exactly you mean? I can't answer your question directly because I'm not sure what you meant, so I'll describe this in full. When merging this PR, we should use the "create a merge commit" merge strategy: When creating the merge commit, we can follow the same pattern as in previous merge commits, e.g., 0210a2f. You'll have to edit the subject and body fields accordingly. E.g.: We should not use the "squash and merge" merge strategy. Doing so would squash all commits in this PR into a single commit. Such a commit would be massive, it would include all generated code, and it's not viable to meaningfully describe the changes that went into adding Go 1.12 support. However, before doing the merge, it is completely acceptable and in fact preferable to re-write the PR history to clean it up and squash redundant commits, so that it consists of clean logical well-described changes. At the very least:
If any of the other commits are redundant or WIP (e.g., where you tried one thing, but ended up overwriting it a future commit) and can be squashed into a single logical commit with a descriptive commit message, that's great too. Of course, re-writing the history involves a force push to this PR branch, so be careful, and do a diff of the final result against the starting point (i.e., the latest commit is a02f42a right now) to ensure the end result is unchanged. Finally, feel free to look over the previous PRs to get an idea of how it was done historically. I've linked them all in #900 (comment). Cleaning up the PR history and writing more descriptive commit messages is great, but optional. Feel free to do as much or as little before merging this PR. Thanks again @hajimehoshi! |
What I wanted to ask is whether we should use this strategy. Sorry for my unclear question. Thanks! |
On Darwin, syscall was instroduced at golang/go@a3b0144. This change renames syscall to avoid collision.
`go tool vet` is abandoned. Use `go vet` instead.
The implementation is mock.
Still work in progress.
I removes some redundant commits, but I couldn't integrate go-generating into one commit. That's not perfect, but I believe that's acceptable. |
Done on darwin/amd64 environment. Regenerated with: go generate github.com/gopherjs/gopherjs.github.io/playground Follows gopherjs/gopherjs#900.
This PR fixes implementation and tests in order to support Go 1.12.
Fixes #887
PTAL