Exemplo n.º 1
0
func init() {
	name := setUp()
	createSmallFile(name)
	createBigFile(name)

	memFS, err = memfs.New(name)
	if err != nil {
		log.Fatal(err)
	}
	go startServer(memFS, "/memfs/", ":6666")

	diskFS = http.Dir(name)
	go startServer(diskFS, "/diskfs/", ":7777")

	time.Sleep(5 * time.Second)
	fmt.Printf("ready to benchmark ...\n")
}
Exemplo n.º 2
0
func main() {
	path := flag.String("path", "./", "")
	addr := flag.String("addr", ":9999", "")
	verbose := flag.Bool("verbose", true, "")
	flag.Parse()

	fs, err := memfs.New(*path)
	if err != nil {
		log.Fatalf("Failed to create memfs: %s err: %v", *path, err)
	}

	if *verbose {
		log.Printf("logging to stderr ...")
		memfs.SetLogger(memfs.Verbose)
	}

	http.Handle("/memfs/", http.StripPrefix("/memfs/", http.FileServer(fs)))

	log.Printf("path: %s addr:%s", *path, *addr)
	log.Fatal(http.ListenAndServe(*addr, nil))
}