File tree 6 files changed +26
-281
lines changed
6 files changed +26
-281
lines changed Original file line number Diff line number Diff line change 1
- //go:build gopherjsdev
2
- // +build gopherjsdev
3
-
4
1
package gopherjspkg
5
2
6
3
import (
7
- "go/build "
4
+ "io/fs "
8
5
"net/http"
9
- "os"
10
- pathpkg "path"
11
-
12
- "github.com/shurcooL/httpfs/filter"
13
- log "github.com/sirupsen/logrus"
14
6
)
15
7
16
8
// FS is a virtual filesystem that contains core GopherJS packages.
17
- var FS = filter .Keep (
18
- http .Dir (importPathToDir ("github.com/gopherjs/gopherjs" )),
19
- func (path string , fi os.FileInfo ) bool {
20
- return path == "/" ||
21
- path == "/js" || (pathpkg .Dir (path ) == "/js" && ! fi .IsDir ()) ||
22
- path == "/nosync" || (pathpkg .Dir (path ) == "/nosync" && ! fi .IsDir ())
23
- },
24
- )
9
+ var FS http.FileSystem
25
10
26
- func importPathToDir (importPath string ) string {
27
- p , err := build .Import (importPath , "" , build .FindOnly )
28
- if err != nil {
29
- log .Fatalln (err )
30
- }
31
- return p .Dir
11
+ // RegisterFS allows setting the embedded fs from another package.
12
+ func RegisterFS (fs fs.ReadDirFS ) {
13
+ FS = http .FS (fs )
32
14
}
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ // This file exists to embed the js/ and nosync/ directories. The "embed"
2
+ // package only supports embedding files stored beneath the directory level
3
+ // of the go:embed directive, so we do the embedding here, then inject the
4
+ // fs reference to the gopherjspkg package, where it's used. In the future we
5
+ // may wish to refactor that, as the gopherjspkg package may not really be
6
+ // necessary at all any more.
7
+
8
+ package main
9
+
10
+ import (
11
+ "embed"
12
+
13
+ "github.com/gopherjs/gopherjs/compiler/gopherjspkg"
14
+ )
15
+
16
+ //go:embed js nosync
17
+ var fs embed.FS
18
+
19
+ func init () {
20
+ gopherjspkg .RegisterFS (fs )
21
+ }
Original file line number Diff line number Diff line change @@ -8,8 +8,6 @@ require (
8
8
github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86
9
9
github.com/neelance/sourcemap v0.0.0-20200213170602-2833bce08e4c
10
10
github.com/shurcooL/go v0.0.0-20200502201357-93f07166e636
11
- github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749
12
- github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546
13
11
github.com/sirupsen/logrus v1.8.1
14
12
github.com/spf13/cobra v1.2.1
15
13
github.com/spf13/pflag v1.0.5
Original file line number Diff line number Diff line change @@ -209,11 +209,7 @@ github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb
209
209
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 /go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc =
210
210
github.com/shurcooL/go v0.0.0-20200502201357-93f07166e636 h1:aSISeOcal5irEhJd1M+IrApc0PdcN7e7Aj4yuEnOrfQ =
211
211
github.com/shurcooL/go v0.0.0-20200502201357-93f07166e636 /go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk =
212
- github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 h1:bUGsEnyNbVPw06Bs80sCeARAlK8lhwqGyi6UT8ymuGk =
213
- github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 /go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg =
214
212
github.com/shurcooL/sanitized_anchor_name v1.0.0 /go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc =
215
- github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546 h1:pXY9qYc/MP5zdvqWEUH6SjNiu7VhSjuVFTFiTcphaLU =
216
- github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546 /go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw =
217
213
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE =
218
214
github.com/sirupsen/logrus v1.8.1 /go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0 =
219
215
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d /go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc =
You can’t perform that action at this time.
0 commit comments