File tree 8 files changed +74
-10
lines changed
8 files changed +74
-10
lines changed Original file line number Diff line number Diff line change @@ -44,10 +44,9 @@ func (s *Setting) Value() string {
44
44
// again each time the environment variable changes
45
45
// (due to use of os.Setenv, for example).
46
46
//
47
- // GOPHERJS: For JS we currently will not be able
48
- // to access $GODEBUG via process.env nor watch
49
- // for changes via syscall.runtimeSetenv and
50
- // syscall.runtimeUnsetenv
47
+ // GOPHERJS: Currently we don't inject a proxy into process.env to watch
48
+ // for changes via syscall.runtimeSetenv and syscall.runtimeUnsetenv.
49
+ // We may want to look into this in the future.
51
50
func setUpdate (update func (string , string )) {}
52
51
53
52
func update (def , env string ) {
Original file line number Diff line number Diff line change @@ -6,14 +6,14 @@ import (
6
6
"testing"
7
7
)
8
8
9
- func testClientTimeout (t * testing.T , h2 bool ) {
9
+ func testClientTimeout (t * testing.T , mode testMode ) {
10
10
// The original test expects Client.Timeout error to be returned, but under
11
11
// GopherJS an "i/o timeout" error is frequently returned. Otherwise the test
12
12
// seems to be working correctly.
13
13
t .Skip ("Flaky test under GopherJS." )
14
14
}
15
15
16
- func testClientTimeout_Headers (t * testing.T , h2 bool ) {
16
+ func testClientTimeout_Headers (t * testing.T , mode testMode ) {
17
17
// The original test expects Client.Timeout error to be returned, but under
18
18
// GopherJS an "i/o timeout" error is frequently returned. Otherwise the test
19
19
// seems to be working correctly.
Original file line number Diff line number Diff line change @@ -7,10 +7,10 @@ import (
7
7
"testing"
8
8
)
9
9
10
- func testTransportGCRequest (t * testing.T , h2 , body bool ) {
10
+ func testTransportGCRequest (t * testing.T , mode testMode , body bool ) {
11
11
t .Skip ("The test relies on runtime.SetFinalizer(), which is not supported by GopherJS." )
12
12
}
13
13
14
- func testWriteHeaderAfterWrite (t * testing.T , h2 , hijack bool ) {
14
+ func testWriteHeaderAfterWrite (t * testing.T , mode testMode , hijack bool ) {
15
15
t .Skip ("GopherJS source maps don't preserve original function names in stack traces, which this test relied on." )
16
16
}
Original file line number Diff line number Diff line change @@ -6,10 +6,15 @@ package http
6
6
import (
7
7
"bufio"
8
8
"bytes"
9
+ "context"
10
+ "crypto/tls"
9
11
"errors"
10
12
"io"
13
+ "net"
11
14
"net/textproto"
12
15
"strconv"
16
+ "sync"
17
+ "sync/atomic"
13
18
14
19
"github.com/gopherjs/gopherjs/js"
15
20
)
@@ -113,3 +118,30 @@ func (t *XHRTransport) CancelRequest(req *Request) {
113
118
xhr .Call ("abort" )
114
119
}
115
120
}
121
+
122
+ type conn struct {
123
+ server * Server
124
+ cancelCtx context.CancelFunc
125
+ rwc net.Conn
126
+ remoteAddr string
127
+ tlsState * tls.ConnectionState
128
+ werr error
129
+ r * connReader
130
+ bufr * bufio.Reader
131
+ bufw * bufio.Writer
132
+ lastMethod string
133
+
134
+ // temporarily replacement of `atomic.Pointer[response]` for go1.20 without generics.
135
+ curReq atomicResponsePointer
136
+
137
+ curState atomic.Uint64
138
+ mu sync.Mutex
139
+ hijackedv bool
140
+ }
141
+
142
+ type atomicResponsePointer struct {
143
+ v * response
144
+ }
145
+
146
+ func (x * atomicResponsePointer ) Load () * response { return x .v }
147
+ func (x * atomicResponsePointer ) Store (val * response ) { x .v = val }
Original file line number Diff line number Diff line change @@ -18,5 +18,9 @@ func TestCompareStrings(t *testing.T) {
18
18
}
19
19
20
20
func TestClone (t * testing.T ) {
21
- t .Skip ("conversion to reflect.StringHeader is not supported in GopherJS" )
21
+ t .Skip ("conversion to unsafe.StringData is not supported in GopherJS" )
22
+ }
23
+
24
+ func TestMap (t * testing.T ) {
25
+ t .Skip ("identity test uses unsafe.StringData is not supported in GopherJS" )
22
26
}
Original file line number Diff line number Diff line change @@ -221,5 +221,19 @@ func sameType(x, y interface{}) bool {
221
221
return js .InternalObject (x ).Get ("constructor" ) == js .InternalObject (y ).Get ("constructor" )
222
222
}
223
223
224
- //gopherjs:purge for go1.19 without generics
224
+ // Override pointer so that the type check in the source code is satisfied
225
+ // but remove the fields and methods for go1.20 without generics.
226
+ // See https://cs.opensource.google/go/go/+/refs/tags/go1.20.14:src/sync/atomic/type.go;l=40
225
227
type Pointer [T any ] struct {}
228
+
229
+ //gopherjs:purge for go1.20 without generics
230
+ func (x * Pointer [T ]) Load () * T
231
+
232
+ //gopherjs:purge for go1.20 without generics
233
+ func (x * Pointer [T ]) Store (val * T )
234
+
235
+ //gopherjs:purge for go1.20 without generics
236
+ func (x * Pointer [T ]) Swap (new * T ) (old * T )
237
+
238
+ //gopherjs:purge for go1.20 without generics
239
+ func (x * Pointer [T ]) CompareAndSwap (old , new * T ) (swapped bool )
Original file line number Diff line number Diff line change @@ -22,6 +22,14 @@ func runtime_envs() []string {
22
22
return envs
23
23
}
24
24
25
+ func runtimeSetenv (k , v string ) {
26
+ setenv_c (k , v )
27
+ }
28
+
29
+ func runtimeUnsetenv (k string ) {
30
+ unsetenv_c (k )
31
+ }
32
+
25
33
func setenv_c (k , v string ) {
26
34
process := js .Global ().Get ("process" )
27
35
if process .IsUndefined () {
Original file line number Diff line number Diff line change
1
+ //go:build js
2
+ // +build js
3
+
4
+ package time
5
+
6
+ // replaced for go1.20 temporarily without generics.
7
+ var ParseRFC3339 = parseRFC3339
You can’t perform that action at this time.
0 commit comments