github.com/hanwen/go-fuse@v1.0.0/example/memfs/main.go (about) 1 // Copyright 2016 the Go-FUSE Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Mounts MemNodeFs for testing purposes. 6 7 package main 8 9 import ( 10 "flag" 11 "fmt" 12 "os" 13 14 "github.com/hanwen/go-fuse/fuse" 15 "github.com/hanwen/go-fuse/fuse/nodefs" 16 ) 17 18 func main() { 19 // Scans the arg list and sets up flags 20 debug := flag.Bool("debug", false, "print debugging messages.") 21 flag.Parse() 22 if flag.NArg() < 2 { 23 // TODO - where to get program name? 24 fmt.Println("usage: main MOUNTPOINT BACKING-PREFIX") 25 os.Exit(2) 26 } 27 28 mountPoint := flag.Arg(0) 29 prefix := flag.Arg(1) 30 root := nodefs.NewMemNodeFSRoot(prefix) 31 conn := nodefs.NewFileSystemConnector(root, nil) 32 server, err := fuse.NewServer(conn.RawFS(), mountPoint, &fuse.MountOptions{ 33 Debug: *debug, 34 }) 35 if err != nil { 36 fmt.Printf("Mount fail: %v\n", err) 37 os.Exit(1) 38 } 39 fmt.Println("Mounted!") 40 server.Serve() 41 }