Skip to content

[go1.20] Native overrides for go1.20 (not generics related) #1310

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

Merged
merged 1 commit into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build js
// +build js

package slicereader

// Overwritten to avoid `unsafe.String`
func toString(b []byte) string {
return string(b)
}
9 changes: 9 additions & 0 deletions compiler/natives/src/math/rand/rand.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build js
// +build js

package rand

import _ "unsafe"

//go:linkname fastrand64 runtime.fastrand64
func fastrand64() uint64
4 changes: 2 additions & 2 deletions compiler/natives/src/net/http/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"testing"
)

func testClientTimeout(t *testing.T, h2 bool) {
func testClientTimeout(t *testing.T, mode testMode) {
// The original test expects Client.Timeout error to be returned, but under
// GopherJS an "i/o timeout" error is frequently returned. Otherwise the test
// seems to be working correctly.
t.Skip("Flaky test under GopherJS.")
}

func testClientTimeout_Headers(t *testing.T, h2 bool) {
func testClientTimeout_Headers(t *testing.T, mode testMode) {
// The original test expects Client.Timeout error to be returned, but under
// GopherJS an "i/o timeout" error is frequently returned. Otherwise the test
// seems to be working correctly.
Expand Down
4 changes: 2 additions & 2 deletions compiler/natives/src/net/http/clientserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"testing"
)

func testTransportGCRequest(t *testing.T, h2, body bool) {
func testTransportGCRequest(t *testing.T, mode testMode, body bool) {
t.Skip("The test relies on runtime.SetFinalizer(), which is not supported by GopherJS.")
}

func testWriteHeaderAfterWrite(t *testing.T, h2, hijack bool) {
func testWriteHeaderAfterWrite(t *testing.T, mode testMode, hijack bool) {
t.Skip("GopherJS source maps don't preserve original function names in stack traces, which this test relied on.")
}
6 changes: 5 additions & 1 deletion compiler/natives/src/strings/strings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@ func TestCompareStrings(t *testing.T) {
}

func TestClone(t *testing.T) {
t.Skip("conversion to reflect.StringHeader is not supported in GopherJS")
t.Skip("conversion to unsafe.StringData is not supported in GopherJS")
}

func TestMap(t *testing.T) {
t.Skip("identity test uses unsafe.StringData is not supported in GopherJS")
}
8 changes: 8 additions & 0 deletions compiler/natives/src/syscall/syscall_js_wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ func runtime_envs() []string {
return envs
}

func runtimeSetenv(k, v string) {
setenv_c(k, v)
}

func runtimeUnsetenv(k string) {
unsetenv_c(k)
}

func setenv_c(k, v string) {
process := js.Global().Get("process")
if process.IsUndefined() {
Expand Down
Loading