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