commit 2e7b49d195caaf38417c59d4b24e03c1f077622e
parent bb0460e6d21034eb5b0f3bba35851e4a7261603e
Author: Matsuda Kenji <info@mtkn.jp>
Date: Sat, 23 Dec 2023 09:29:39 +0900
gofmt
Diffstat:
8 files changed, 62 insertions(+), 62 deletions(-)
diff --git a/auth_test.go b/auth_test.go
@@ -6,8 +6,8 @@ import (
"testing"
"git.mtkn.jp/lib9p"
-// "git.mtkn.jp/lib9p/client"
-// "git.mtkn.jp/lib9p/testfs"
+ // "git.mtkn.jp/lib9p/client"
+ // "git.mtkn.jp/lib9p/testfs"
)
func TestAuth(t *testing.T) {
@@ -23,7 +23,7 @@ func TestAuth(t *testing.T) {
}()
conn.s.Auth = func(ctx context.Context, respc chan<- *lib9p.Req) chan<- *lib9p.Req {
c := make(chan *lib9p.Req)
- go func () {
+ go func() {
for {
select {
case <-ctx.Done():
@@ -50,7 +50,7 @@ func TestAuth(t *testing.T) {
return c
}
ctx := context.Background()
- _, _, err := conn.c.Version(ctx, lib9p.NOTAG, 8 * 1024, "9P2000")
+ _, _, err := conn.c.Version(ctx, lib9p.NOTAG, 8*1024, "9P2000")
if err != nil {
t.Log(err)
}
diff --git a/diskfs/uid.go b/diskfs/uid.go
@@ -1,4 +1,5 @@
//go:build unix || windows
+
package diskfs
import (
diff --git a/diskfs/uid_plan9.go b/diskfs/uid_plan9.go
@@ -1,4 +1,5 @@
//go:build plan9
+
package diskfs
import (
@@ -18,14 +19,14 @@ func isGroupLeader(group, uid string) bool {
return false
}
groups := strings.Split(string(b), "\n")
- groups = groups[:len(groups) - 1]
+ groups = groups[:len(groups)-1]
cmd = exec.Command("rc", "-c", "whois "+usr.Username+" | awk -F: '{print }'")
b, err = cmd.Output()
if err != nil {
return false
}
leaders := strings.Split(string(b), "\n")
- leaders = leaders[:len(leaders) - 1]
+ leaders = leaders[:len(leaders)-1]
for i := 0; i < len(groups); i++ {
if groups[i] == group && uid == leaders[i] {
return true
@@ -45,7 +46,7 @@ func isGroupMember(group, uid string) bool {
return false
}
groups := strings.Split(string(b), "\n")
- groups = groups[:len(groups) - 1]
+ groups = groups[:len(groups)-1]
for i := 0; i < len(groups); i++ {
if groups[i] == group {
return true
diff --git a/diskfs/uid_plan9_test.go b/diskfs/uid_plan9_test.go
@@ -1,4 +1,5 @@
//go:build plan9
+
package diskfs
import (
@@ -20,14 +21,14 @@ func TestIsGroupLeader(t *testing.T) {
t.Fatal(err)
}
groups := strings.Split(string(b), "\n")
- groups = groups[:len(groups) - 1]
+ groups = groups[:len(groups)-1]
cmd = exec.Command("rc", "-c", "whois "+usr.Username+" | awk -F: '{print }'")
b, err = cmd.Output()
if err != nil {
t.Fatal(err)
}
leaders := strings.Split(string(b), "\n")
- leaders = leaders[:len(leaders) - 1]
+ leaders = leaders[:len(leaders)-1]
tests := []struct {
name string
uid string
@@ -62,14 +63,13 @@ func TestIsGroupMember(t *testing.T) {
t.Fatal(err)
}
groups := strings.Split(string(b), "\n")
- groups = groups[:len(groups) - 1]
+ groups = groups[:len(groups)-1]
tests := []struct {
name string
uid string
group string
want bool
- }{
- }
+ }{}
for i, grp := range groups {
tests = append(tests, struct {
name string
diff --git a/diskfs/uid_test.go b/diskfs/uid_test.go
@@ -1,4 +1,5 @@
//go:build unix || windows
+
package diskfs
import (
diff --git a/req_test.go b/req_test.go
@@ -47,4 +47,3 @@ func TestFlush(t *testing.T) {
t.Logf("read data: %v, err: %v", data, err)
time.Sleep(testfs.SleepTime * 2)
}
-
diff --git a/server.go b/server.go
@@ -263,7 +263,7 @@ func sAuth(ctx context.Context, s *Server, c <-chan *Req) {
select {
case <-ctx.Done():
return
- case r := <- c:
+ case r := <-c:
if r == nil {
return
}
@@ -377,7 +377,7 @@ func rAttach(ctx context.Context, c <-chan *Req) {
select {
case <-ctx.Done():
return
- case r := <- c:
+ case r := <-c:
if r == nil {
return
}
@@ -504,7 +504,7 @@ func rWalk(ctx context.Context, c <-chan *Req) {
select {
case <-ctx.Done():
return
- case r := <- c:
+ case r := <-c:
if r == nil {
return
}
@@ -946,7 +946,7 @@ func sWrite(ctx context.Context, s *Server, c <-chan *Req) {
if err != nil {
r.err = err
rc <- r
- continue
+ continue
}
case <-r.Done:
continue
@@ -998,7 +998,7 @@ func sClunk(ctx context.Context, s *Server, c <-chan *Req) {
if err := fid.File.Close(); err != nil {
r.err = fmt.Errorf("close: %v", err)
rc <- r
- continue
+ continue
}
}
r.Ofcall = &RClunk{}
@@ -1172,7 +1172,7 @@ func sWStat(ctx context.Context, s *Server, c <-chan *Req) {
if err != nil {
r.err = fmt.Errorf("open: %v", err)
rc <- r
- continue
+ continue
}
defer r.Fid.File.Close()
}
@@ -1208,12 +1208,12 @@ func sWStat(ctx context.Context, s *Server, c <-chan *Req) {
if err != nil {
r.err = fmt.Errorf("stat parent: %v", err)
rc <- r
- continue
+ continue
}
if !hasPerm(s.fs, pstat, r.Fid.Uid, AWRITE) {
r.err = ErrPerm
rc <- r
- continue
+ continue
}
// TODO: I think 9P protocol prohibits renaming to existent file.
// Wstat(9P) in p9p says:
@@ -1221,19 +1221,19 @@ func sWStat(ctx context.Context, s *Server, c <-chan *Req) {
// an existing file.
// but 9pfs, 9pfuse does the rename when used with `git init`.
/*
- children, err := fs.Glob(ExportFS{s.fs}, path.Join(parentPath, "*"))
- if err != nil {
- r.err = fmt.Errorf("glob children: %v", err)
- rc <- r
- continue
- }
- for _, f := range children {
- if path.Base(f) == wstat.Name {
- r.err = fmt.Errorf("file already exists")
+ children, err := fs.Glob(ExportFS{s.fs}, path.Join(parentPath, "*"))
+ if err != nil {
+ r.err = fmt.Errorf("glob children: %v", err)
rc <- r
- continue
+ continue
+ }
+ for _, f := range children {
+ if path.Base(f) == wstat.Name {
+ r.err = fmt.Errorf("file already exists")
+ rc <- r
+ continue
+ }
}
- }
*/
newStat.Name = wstat.Name
}
@@ -1241,7 +1241,7 @@ func sWStat(ctx context.Context, s *Server, c <-chan *Req) {
if fi.IsDir() || !hasPerm(s.fs, fi, r.Fid.Uid, AWRITE) {
r.err = ErrPerm
rc <- r
- continue
+ continue
}
newStat.Length = wstat.Length
}
@@ -1250,12 +1250,12 @@ func sWStat(ctx context.Context, s *Server, c <-chan *Req) {
if r.Fid.Uid != newStat.Uid && r.Fid.Uid != newStat.Gid {
r.err = ErrPerm
rc <- r
- continue
+ continue
}
if wstat.Mode&fs.ModeDir != newStat.Mode&fs.ModeDir {
r.err = ErrPerm
rc <- r
- continue
+ continue
}
newStat.Mode = wstat.Mode
}
@@ -1264,7 +1264,7 @@ func sWStat(ctx context.Context, s *Server, c <-chan *Req) {
if r.Fid.Uid != newStat.Uid && r.Fid.Uid != newStat.Gid {
r.err = ErrPerm
rc <- r
- continue
+ continue
}
newStat.Mtime = wstat.Mtime
}
@@ -1281,7 +1281,7 @@ func sWStat(ctx context.Context, s *Server, c <-chan *Req) {
} else {
r.err = ErrPerm
rc <- r
- continue
+ continue
}
}
err = wsfile.WStat(newStat)
@@ -1321,19 +1321,19 @@ func (s *Server) Serve(ctx context.Context) {
s.runSpeaker(ctx)
var (
versionChan = make(chan *Req)
- authChan = make(chan *Req)
- attachChan = make(chan *Req)
- flushChan = make(chan *Req)
- walkChan = make(chan *Req)
- openChan = make(chan *Req)
- createChan = make(chan *Req)
- readChan = make(chan *Req)
- writeChan = make(chan *Req)
- clunkChan = make(chan *Req)
- removeChan = make(chan *Req)
- statChan = make(chan *Req)
- wstatChan = make(chan *Req)
- )
+ authChan = make(chan *Req)
+ attachChan = make(chan *Req)
+ flushChan = make(chan *Req)
+ walkChan = make(chan *Req)
+ openChan = make(chan *Req)
+ createChan = make(chan *Req)
+ readChan = make(chan *Req)
+ writeChan = make(chan *Req)
+ clunkChan = make(chan *Req)
+ removeChan = make(chan *Req)
+ statChan = make(chan *Req)
+ wstatChan = make(chan *Req)
+ )
defer func() {
close(versionChan)
close(authChan)
@@ -1451,4 +1451,4 @@ func respond(ctx context.Context, s *Server) {
}
}
}
-}
-\ No newline at end of file
+}
diff --git a/server_test.go b/server_test.go
@@ -13,8 +13,8 @@ import (
)
type testConn struct {
- s *lib9p.Server
- c *client.Client
+ s *lib9p.Server
+ c *client.Client
cr, sr *io.PipeReader
cw, sw *io.PipeWriter
cancel context.CancelFunc
@@ -22,7 +22,7 @@ type testConn struct {
// SetupTestConn setups a connection between a server and a client and
// returns those.
-func setupTestConn() (*testConn) {
+func setupTestConn() *testConn {
const (
mSize = 8 * 1024
uname = "kenji"
@@ -35,12 +35,12 @@ func setupTestConn() (*testConn) {
ctx, cancel := context.WithCancel(context.Background())
go s.Serve(ctx)
return &testConn{
- s: s,
- c: c,
- cr: cr,
- cw: cw,
- sr: sr,
- sw: sw,
+ s: s,
+ c: c,
+ cr: cr,
+ cw: cw,
+ sr: sr,
+ sw: sw,
cancel: cancel,
}
}
@@ -77,7 +77,6 @@ func TestWalk(t *testing.T) {
testWalk(t, testfs.FS, ".", testfs.FS.Root)
}
-
// TODO: I don't know what this test acturally tests.
func TestServer(t *testing.T) {
sr, cw := io.Pipe()