func main() { var user ninep.User var file *clnt.File flag.Parse() user = ninep.OsUsers.Uid2User(os.Geteuid()) clnt.DefaultDebuglevel = *debuglevel c, oerr := tls.Dial("tcp", *addr, &tls.Config{ Rand: rand.Reader, InsecureSkipVerify: true, }) if oerr != nil { log.Println("can't dial", oerr) return } clnt, err := clnt.MountConn(c, "", uint32(*msize), user) if err != nil { goto error } if flag.NArg() != 1 { log.Println("invalid arguments") return } file, oerr = clnt.FOpen(flag.Arg(0), ninep.OREAD) if oerr != nil { goto oerror } for { d, oerr := file.Readdir(0) if oerr != nil { goto oerror } if d == nil || len(d) == 0 { break } for i := 0; i < len(d); i++ { os.Stdout.WriteString(d[i].Name + "\n") } } file.Close() return error: log.Println(fmt.Sprintf("Error: %s", err)) return oerror: log.Println("Error", oerr) }
func main() { var user ninep.User var err error var c *clnt.Clnt var file *clnt.File var d []*ninep.Dir flag.Parse() user = ninep.OsUsers.Uid2User(os.Geteuid()) clnt.DefaultDebuglevel = *debuglevel c, err = clnt.Mount("tcp", *addr, "", uint32(*msize), user) if err != nil { log.Fatal(err) } lsarg := "/" if flag.NArg() == 1 { lsarg = flag.Arg(0) } else if flag.NArg() > 1 { log.Fatal("error: only one argument expected") } file, err = c.FOpen(lsarg, ninep.OREAD) if err != nil { log.Fatal(err) } for { d, err = file.Readdir(0) if d == nil || len(d) == 0 || err != nil { break } for i := 0; i < len(d); i++ { os.Stdout.WriteString(d[i].Name + "\n") } } file.Close() if err != nil && err != io.EOF { log.Fatal(err) } return }