Skip to content

Commit e13d1c9

Browse files
committed
compiler/natives: use embed package
It's now possible to use the new embed package in the standard library to simplify the implementation of natives.FS and reduce its dependence on packages outside the standard library. This also drops support for the gopherjsdev tag where the natives could be read directly from disk without regenerating and rebuilding the gopherjs binary. That mode is less helpful now that file changes can be picked up just by rebuilding (without regenerating). It also can't be made to work reliably in module mode since module mode doesn't have the concept of a system-wide always-present workspace like GOPATH mode had. One-off occasional needs can probably be better served by temporary local code changes instead.
1 parent d422bb4 commit e13d1c9

File tree

5 files changed

+9
-1492
lines changed

5 files changed

+9
-1492
lines changed

build/context.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func DefaultEnv() Env {
6060
return e
6161
}
6262

63-
// XContext is an extension of go/build.Context with GopherJS-specifc features.
63+
// XContext is an extension of go/build.Context with GopherJS-specific features.
6464
//
6565
// It abstracts away several different sources GopherJS can load its packages
6666
// from, with a minimal API.
@@ -313,7 +313,7 @@ func embeddedCtx(embedded http.FileSystem, e Env) *simpleCtx {
313313
// overlayCtx creates simpleCtx that imports from the embedded standard library
314314
// overlays.
315315
func overlayCtx(e Env) *simpleCtx {
316-
return embeddedCtx(&withPrefix{fs: natives.FS, prefix: e.GOROOT}, e)
316+
return embeddedCtx(&withPrefix{fs: http.FS(natives.FS), prefix: e.GOROOT}, e)
317317
}
318318

319319
// gopherjsCtx creates a simpleCtx that imports from the embedded gopherjs

compiler/natives/fs.go

-30
This file was deleted.

0 commit comments

Comments
 (0)