File: fs.go

package info (click to toggle)
golang-github-gopherjs-gopherjs 0.0~git20170927.0.4152256-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,464 kB
  • sloc: cpp: 91; makefile: 7
file content (29 lines) | stat: -rw-r--r-- 582 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// +build gopherjsdev

package natives

import (
	"go/build"
	"log"
	"net/http"
	"os"
	"strings"

	"github.com/shurcooL/httpfs/filter"
)

func importPathToDir(importPath string) string {
	p, err := build.Import(importPath, "", build.FindOnly)
	if err != nil {
		log.Fatalln(err)
	}
	return p.Dir
}

// FS is a virtual filesystem that contains native packages.
var FS = filter.Keep(
	http.Dir(importPathToDir("github.com/gopherjs/gopherjs/compiler/natives")),
	func(path string, fi os.FileInfo) bool {
		return path == "/" || path == "/src" || strings.HasPrefix(path, "/src/")
	},
)