🌐 AI搜索 & 代理 主页
Skip to content

Commit bb26745

Browse files
authored
Go 1.12 support (version bump to GopherJS 1.12-1).
Merge pull request #900 from gopherjs/go1.12
2 parents 847fc94 + 09ef6f4 commit bb26745

File tree

24 files changed

+461
-193
lines changed

24 files changed

+461
-193
lines changed

.std_test_pkg_exclusions

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
context
22
crypto
3-
crypto/internal/randutil
4-
crypto/internal/subtle
3+
crypto/internal/cipherhw
54
crypto/tls
65
crypto/x509/pkix
76
debug/gosym
@@ -16,8 +15,8 @@ go/types
1615
hash
1716
image/color/palette
1817
image/internal/imageutil
19-
internal/bytealg
2018
internal/cpu
19+
internal/goroot
2120
internal/nettrace
2221
internal/poll
2322
internal/race
@@ -29,6 +28,7 @@ internal/syscall/windows/sysdll
2928
internal/testenv
3029
internal/testlog
3130
internal/trace
31+
internal/x/net/nettest
3232
log
3333
log/syslog
3434
net
@@ -52,6 +52,7 @@ runtime
5252
runtime/cgo
5353
runtime/debug
5454
runtime/internal/atomic
55+
runtime/internal/math
5556
runtime/internal/sys
5657
runtime/pprof
5758
runtime/pprof/internal/profile
@@ -62,22 +63,3 @@ testing
6263
testing/internal/testdeps
6364
testing/iotest
6465
unsafe
65-
vendor/golang_org/x/crypto/chacha20poly1305
66-
vendor/golang_org/x/crypto/cryptobyte
67-
vendor/golang_org/x/crypto/cryptobyte/asn1
68-
vendor/golang_org/x/crypto/curve25519
69-
vendor/golang_org/x/crypto/internal/chacha20
70-
vendor/golang_org/x/crypto/poly1305
71-
vendor/golang_org/x/net/dns/dnsmessage
72-
vendor/golang_org/x/net/http/httpguts
73-
vendor/golang_org/x/net/http/httpproxy
74-
vendor/golang_org/x/net/http2/hpack
75-
vendor/golang_org/x/net/idna
76-
vendor/golang_org/x/net/internal/nettest
77-
vendor/golang_org/x/net/nettest
78-
vendor/golang_org/x/text/secure
79-
vendor/golang_org/x/text/secure/bidirule
80-
vendor/golang_org/x/text/transform
81-
vendor/golang_org/x/text/unicode
82-
vendor/golang_org/x/text/unicode/bidi
83-
vendor/golang_org/x/text/unicode/norm

circle.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- checkout
1212
- run: git clone https://github.com/creationix/nvm $HOME/.nvm && cd $HOME/.nvm && git checkout v0.33.9 && echo 'export NVM_DIR="$HOME/.nvm"' >> $BASH_ENV && echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV
1313
- run: nvm install 10.0.0 && nvm alias default 10.0.0
14-
- run: cd /usr/local && sudo rm -rf go && curl https://storage.googleapis.com/golang/go1.11.5.linux-amd64.tar.gz | sudo tar -xz
14+
- run: cd /usr/local && sudo rm -rf go && curl https://storage.googleapis.com/golang/go1.12.linux-amd64.tar.gz | sudo tar -xz
1515
- run: echo 'export PATH="$PATH:/usr/local/go/bin:$HOME/go/bin"' >> $BASH_ENV
1616
- run: go get -t -d -v ./...
1717
- run: go install -v
@@ -22,8 +22,8 @@ jobs:
2222
- run: go generate github.com/gopherjs/gopherjs/compiler/prelude
2323
- run: diff -u <(echo -n) <(git status --porcelain)
2424
- run: diff -u <(echo -n) <(gofmt -d .)
25-
- run: go tool vet *.go # Go package in root directory.
26-
- 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".
25+
- run: go vet . # Go package in root directory.
26+
- run: for d in */; do echo ./$d...; done | grep -v ./doc | grep -v ./tests | grep -v ./node | xargs go vet # All subdirectories except "doc", "tests", "node*".
2727
- run: diff -u <(echo -n) <(go list ./compiler/natives/src/...) # All those packages should have // +build js.
2828
- run: gopherjs install -v net/http # Should build successfully (can't run tests, since only client is supported).
2929
- run: ulimit -s 10000 && gopherjs test --minify -v --short github.com/gopherjs/gopherjs/tests/... $(go list std | grep -v -x -f .std_test_pkg_exclusions)

compiler/compiler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717

1818
var sizes32 = &types.StdSizes{WordSize: 4, MaxAlign: 8}
1919
var reservedKeywords = make(map[string]bool)
20-
var _ = ___GOPHERJS_REQUIRES_GO_VERSION_1_11___ // Compile error on other Go versions, because they're not supported.
20+
var _ = ___GOPHERJS_REQUIRES_GO_VERSION_1_12___ // Compile error on other Go versions, because they're not supported.
2121

2222
func init() {
2323
for _, keyword := range []string{"abstract", "arguments", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "eval", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "let", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "typeof", "undefined", "var", "void", "volatile", "while", "with", "yield"} {

compiler/gopherjspkg/fs_vfsdata.go

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiler/natives/fs_vfsdata.go

Lines changed: 189 additions & 134 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiler/natives/src/crypto/rand/rand.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,15 @@ func (r *rngReader) Read(b []byte) (n int, err error) {
4747

4848
return 0, errors.New("crypto/rand not available in this environment")
4949
}
50+
51+
func batched(f func([]byte) bool, readMax int) func([]byte) bool {
52+
return func(buf []byte) bool {
53+
for len(buf) > readMax {
54+
if !f(buf[:readMax]) {
55+
return false
56+
}
57+
buf = buf[readMax:]
58+
}
59+
return len(buf) == 0 || f(buf)
60+
}
61+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// +build js
2+
3+
package bytealg
4+
5+
func Equal(a, b []byte) bool {
6+
if len(a) != len(b) {
7+
return false
8+
}
9+
for i, c := range a {
10+
if c != b[i] {
11+
return false
12+
}
13+
}
14+
return true
15+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// +build js
2+
3+
package cpu
4+
5+
const (
6+
CacheLineSize = 0
7+
CacheLinePadSize = 0
8+
)

compiler/natives/src/internal/cpu/cpu_js.go

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// +build js
2+
3+
package fmtsort_test
4+
5+
import (
6+
"math"
7+
"reflect"
8+
"testing"
9+
10+
"internal/fmtsort"
11+
)
12+
13+
// needsSkip reports whether the kind doesn't work for sorting on GopherJS.
14+
func needsSkip(k reflect.Kind) bool {
15+
switch k {
16+
case reflect.Ptr, reflect.Chan:
17+
return true
18+
}
19+
return false
20+
}
21+
22+
// Note: sync with the original TestCompare.
23+
func TestCompare(t *testing.T) {
24+
for _, test := range compareTests {
25+
for i, v0 := range test {
26+
for j, v1 := range test {
27+
if needsSkip(v0.Kind()) {
28+
continue
29+
}
30+
if needsSkip(v1.Kind()) {
31+
continue
32+
}
33+
34+
c := fmtsort.Compare(v0, v1)
35+
var expect int
36+
switch {
37+
case i == j:
38+
expect = 0
39+
// NaNs are tricky.
40+
if typ := v0.Type(); (typ.Kind() == reflect.Float32 || typ.Kind() == reflect.Float64) && math.IsNaN(v0.Float()) {
41+
expect = -1
42+
}
43+
case i < j:
44+
expect = -1
45+
case i > j:
46+
expect = 1
47+
}
48+
if c != expect {
49+
t.Errorf("%s: compare(%v,%v)=%d; expect %d", v0.Type(), v0, v1, c, expect)
50+
}
51+
}
52+
}
53+
}
54+
}
55+
56+
func TestOrder(t *testing.T) {
57+
t.Skip("known issue: nil key doesn't work")
58+
}

0 commit comments

Comments
 (0)