github.com/goplusjs/gopherjs@v1.2.6-0.20211206034512-f187917453b8/compiler/natives/fs.go (about) 1 // +build gopherjsdev 2 3 package natives 4 5 import ( 6 "fmt" 7 "go/build" 8 "log" 9 "net/http" 10 "os" 11 "strings" 12 13 "github.com/shurcooL/httpfs/filter" 14 ) 15 16 // FS is a virtual filesystem that contains native packages. 17 var FS = filter.Keep( 18 http.Dir(importPathToDir("github.com/goplusjs/gopherjs/compiler/natives")), 19 func(path string, fi os.FileInfo) bool { 20 return path == "/" || path == "/src" || strings.HasPrefix(path, "/src/") 21 }, 22 ) 23 24 func importPathToDir(importPath string) string { 25 p, err := build.Import(importPath, "", build.FindOnly) 26 if err != nil { 27 log.Fatalln(err) 28 } 29 fmt.Println("gopherjsdev importpath:", p.Dir) 30 return p.Dir 31 }