lib9p

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

commit 8a667df91124da092c26a83a212afbbdd731d72c
parent 377eafaf26ad5b5ef78ff34ac8f5e731ad0707f4
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Thu,  4 Jan 2024 12:03:24 +0900

gofmt

Diffstat:
Mcmd/diskfs/main.go | 2+-
Mdoc.go | 24++++++++++++------------
Mfile_test.go | 2+-
Mfs_test.go | 24++++++++++++------------
Mreq_test.go | 14+++++++-------
Mserver.go | 4++--
Muid.go | 3+--
7 files changed, 36 insertions(+), 37 deletions(-)

diff --git a/cmd/diskfs/main.go b/cmd/diskfs/main.go @@ -77,7 +77,7 @@ L: } } wg.Add(1) - go func () { + go func() { defer conn.Close() defer wg.Done() s.Serve(ctx, conn, conn) diff --git a/doc.go b/doc.go @@ -11,18 +11,18 @@ // If the server is to serve via a tcp connection, write something like the // following code: // -// l, err := net.Listen("tcp", "localhost:5640") -// if err != nil { -// log.Fatal(err) -// } -// for { -// conn, err := l.Accept() -// if err != nil { -// log.Print(err) -// } -// s := lib9p.NewServer(fsys) // fsys is user defined *FS. -// go s.Serve(context.Background(), conn, conn) -// } +// l, err := net.Listen("tcp", "localhost:5640") +// if err != nil { +// log.Fatal(err) +// } +// for { +// conn, err := l.Accept() +// if err != nil { +// log.Print(err) +// } +// s := lib9p.NewServer(fsys) // fsys is user defined *FS. +// go s.Serve(context.Background(), conn, conn) +// } // // OpenFile method of [FS] interface is similar to that of [os.OpenFile], // but it takes as argument OpenMode instead of integer flag. diff --git a/file_test.go b/file_test.go @@ -21,7 +21,7 @@ func BenchmarkRead(b *testing.B) { } fid.path = "dir/file" for i := 0; i < b.N; i++ { - tc <- &request{ifcall:&TRead{Count:8*1024}} + tc <- &request{ifcall: &TRead{Count: 8 * 1024}} if rerr, ok := (<-rc).ofcall.(*RError); ok { b.Fatal(rerr.Ename) } diff --git a/fs_test.go b/fs_test.go @@ -97,7 +97,7 @@ type testFS struct { root *testFile // If slow is true, each function on files of this testFS waits for // something arrives on waitc. - slow bool + slow bool nextQid uint64 // waitc is used to wait some timing to emulate slow response. waitc chan struct{} @@ -139,7 +139,7 @@ func (fs *testFS) IsGroupMember(gid, uid string) bool { // Permission check is intentionally skipped. func (fs *testFS) Create(name string, uid string, mode OpenMode, perm FileMode) (File, error) { dirname, filename := path.Split(name) - if dirname == "" && (filename == "." || filename == "" ) { + if dirname == "" && (filename == "." || filename == "") { return nil, fmt.Errorf("cant create root") } dir, err := fs.walkPath(path.Dir(dirname)) @@ -152,20 +152,20 @@ func (fs *testFS) Create(name string, uid string, mode OpenMode, perm FileMode) } } f := &testFile{ - fsys: fs, + fsys: fs, parent: dir, stat: Stat{ Qid: Qid{ Type: FSModeToQidType(perm), Path: fs.nextQid, }, - Mode: perm, + Mode: perm, Atime: uint32(time.Now().Unix()), Mtime: uint32(time.Now().Unix()), - Name: filename, - Uid: uid, - Gid: dir.stat.Gid, - Muid: uid, + Name: filename, + Uid: uid, + Gid: dir.stat.Gid, + Muid: uid, }, } fs.nextQid++ @@ -270,19 +270,19 @@ func init() { testfs.waitc = make(chan struct{}) testfs.groups = map[string]group{ "glenda": group{ - leader: "glenda", + leader: "glenda", members: map[string]bool{"glenda": true}, }, "ken": group{ - leader: "ken", + leader: "ken", members: map[string]bool{"ken": true}, }, "brian": group{ - leader: "brian", + leader: "brian", members: map[string]bool{"brian": true}, }, "rob": group{ - leader: "rob", + leader: "rob", members: map[string]bool{"rob": true}, }, "bell": group{ diff --git a/req_test.go b/req_test.go @@ -34,30 +34,30 @@ func TestFlush(t *testing.T) { fid.path = "dir/file" fid.omode = ORDWR req := &request{ - ifcall: &TRead{Count: mSize-IOHDRSZ}, - done: make(chan struct{}), - pool: newReqPool(), + ifcall: &TRead{Count: mSize - IOHDRSZ}, + done: make(chan struct{}), + pool: newReqPool(), } rtc <- req <-testfs.waitc ftc <- &request{ifcall: &TFlush{Tag: 1, Oldtag: 0}, oldreq: req} <-rc testfs.waitc <- struct{}{} // TODO: race? - if _, ok := <- req.done; ok { + if _, ok := <-req.done; ok { t.Error("req not flushed.") } data := []byte("data") req = &request{ ifcall: &TWrite{Count: uint32(len(data)), Data: data}, - done: make(chan struct{}), - pool: newReqPool(), + done: make(chan struct{}), + pool: newReqPool(), } wtc <- req <-testfs.waitc ftc <- &request{ifcall: &TFlush{Tag: 1, Oldtag: 0}, oldreq: req} <-rc testfs.waitc <- struct{}{} // TODO: race? - if _, ok := <- req.done; ok { + if _, ok := <-req.done; ok { t.Error("req not flushed.") } } diff --git a/server.go b/server.go @@ -249,7 +249,7 @@ func sAuth(ctx context.Context, c *conn, rc <-chan *request) { return } var ( - err error + err error ifcall *TAuth ) if c.s.Auth == nil { @@ -266,7 +266,7 @@ func sAuth(ctx context.Context, c *conn, rc <-chan *request) { r.err = ErrDupFid goto resp } -resp: + resp: if r.err != nil { setError(r, r.err) } else { diff --git a/uid.go b/uid.go @@ -46,4 +46,4 @@ func isGroupLeader(fsys FS, gid, uid string) bool { return fsys.IsGroupLeader(gid, uid) } return gid == uid -} -\ No newline at end of file +}