lib9p

Go 9P library.
Log | Files | Refs | LICENSE

doc.go (1607B)


      1 // Package lib9p is a 9P2000 library to implement 9P servers.
      2 // For detailed information on 9P protocol, consult the protocol's documentation.
      3 //
      4 // To use this package, implement the [FS] interface, and
      5 // create a [Server] struct by calling [NewServer] with the [FS], and
      6 // then call [*Server.Serve].
      7 // The server listens to r specified by the argument of [NewServer] and
      8 // writes responses to w.
      9 // It does not assume network connection, and can be used with any
     10 // [io.Reader]/[io.Writer].
     11 // If the server is to serve via a tcp connection, write something like the
     12 // following code:
     13 //
     14 //	l, err := net.Listen("tcp", "localhost:5640")
     15 //	if err != nil {
     16 //		log.Fatal(err)
     17 //	}
     18 //	for {
     19 //		conn, err := l.Accept()
     20 //		if err != nil {
     21 //			log.Print(err)
     22 //		}
     23 //		s := lib9p.NewServer(fsys) // fsys is user defined *FS.
     24 //		go s.Serve(context.Background(), conn, conn)
     25 //	}
     26 //
     27 // OpenFile method of [FS] interface is similar to that of [os.OpenFile],
     28 // but it takes as argument OpenMode instead of integer flag.
     29 // And it does not create file even if the specified file does not exists.
     30 // The returned value is [File], not [fs.File].
     31 //
     32 // A [File] is the representation of a file of the exported file system.
     33 // It is almost identical to [fs.File], but the Stat method returns the
     34 // [*FileInfo] struct instead of [fs.FileInfo] interface.
     35 // The difference of [*FileInfo] and [fs.FileInfo] is that the Sys method
     36 // of [*FileInfo] returns the underlying [*Stat] struct as a value of any,
     37 // while I can't asume anything on Stat of [fs.FileInfo].
     38 // This ensures the type safety.
     39 package lib9p