From 11770e0d51a6783322b7b1c186a2d4fb29bffd62 Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Sun, 1 Sep 2019 17:50:21 -0400 Subject: [PATCH] and i feel it slowing down --- fs/info.go | 18 ------------------ fs/memfs/http.go | 1 - fs/{memfs => memwh}/create.go | 2 +- fs/{memfs => memwh}/create_test.go | 2 +- fs/{memfs => memwh}/file.go | 2 +- fs/{memfs => memwh}/file_test.go | 2 +- fs/memwh/http.go | 1 + fs/{memfs => memwh}/http_test.go | 2 +- fs/{memfs => memwh}/json.go | 2 +- fs/{memfs => memwh}/json_test.go | 2 +- fs/{memfs => memwh}/memfs.go | 2 +- fs/{memfs => memwh}/memfs_test.go | 2 +- fs/{memfs => memwh}/mkdirall.go | 2 +- fs/{memfs => memwh}/mkdirall_test.go | 2 +- fs/{memfs => memwh}/open.go | 2 +- fs/{memfs => memwh}/open_test.go | 2 +- fs/{memfs => memwh}/stat.go | 2 +- fs/{memfs => memwh}/stat_test.go | 2 +- fs/{memfs => memwh}/walk.go | 2 +- fs/{memfs => memwh}/walk_test.go | 2 +- fs/mod_time.go | 24 ++++++++++++++++++++++++ fs/{fs.go => warehouse.go} | 0 22 files changed, 42 insertions(+), 36 deletions(-) delete mode 100644 fs/memfs/http.go rename fs/{memfs => memwh}/create.go (97%) rename fs/{memfs => memwh}/create_test.go (99%) rename fs/{memfs => memwh}/file.go (99%) rename fs/{memfs => memwh}/file_test.go (98%) create mode 100644 fs/memwh/http.go rename fs/{memfs => memwh}/http_test.go (99%) rename fs/{memfs => memwh}/json.go (98%) rename fs/{memfs => memwh}/json_test.go (97%) rename fs/{memfs => memwh}/memfs.go (99%) rename fs/{memfs => memwh}/memfs_test.go (96%) rename fs/{memfs => memwh}/mkdirall.go (98%) rename fs/{memfs => memwh}/mkdirall_test.go (96%) rename fs/{memfs => memwh}/open.go (97%) rename fs/{memfs => memwh}/open_test.go (97%) rename fs/{memfs => memwh}/stat.go (94%) rename fs/{memfs => memwh}/stat_test.go (96%) rename fs/{memfs => memwh}/walk.go (97%) rename fs/{memfs => memwh}/walk_test.go (98%) create mode 100644 fs/mod_time.go rename fs/{fs.go => warehouse.go} (100%) diff --git a/fs/info.go b/fs/info.go index 75721db..87db439 100644 --- a/fs/info.go +++ b/fs/info.go @@ -7,24 +7,6 @@ import ( "time" ) -const timeFmt = time.RFC3339Nano - -type ModTime time.Time - -func (m ModTime) MarshalJSON() ([]byte, error) { - t := time.Time(m) - return json.Marshal(t.Format(timeFmt)) -} - -func (m *ModTime) UnmarshalJSON(b []byte) error { - t := time.Time{} - if err := json.Unmarshal(b, &t); err != nil { - return err - } - (*m) = ModTime(t) - return nil -} - type Details struct { Name string `json:"name"` Size int64 `json:"size"` diff --git a/fs/memfs/http.go b/fs/memfs/http.go deleted file mode 100644 index 8151e03..0000000 --- a/fs/memfs/http.go +++ /dev/null @@ -1 +0,0 @@ -package memfs diff --git a/fs/memfs/create.go b/fs/memwh/create.go similarity index 97% rename from fs/memfs/create.go rename to fs/memwh/create.go index b4eeb09..6d7a543 100644 --- a/fs/memfs/create.go +++ b/fs/memwh/create.go @@ -1,4 +1,4 @@ -package memfs +package memwh import ( "path/filepath" diff --git a/fs/memfs/create_test.go b/fs/memwh/create_test.go similarity index 99% rename from fs/memfs/create_test.go rename to fs/memwh/create_test.go index 1761e64..47d6526 100644 --- a/fs/memfs/create_test.go +++ b/fs/memwh/create_test.go @@ -1,4 +1,4 @@ -package memfs +package memwh // func Test_Create(t *testing.T) { // r := require.New(t) diff --git a/fs/memfs/file.go b/fs/memwh/file.go similarity index 99% rename from fs/memfs/file.go rename to fs/memwh/file.go index c6192ff..618b281 100644 --- a/fs/memfs/file.go +++ b/fs/memwh/file.go @@ -1,4 +1,4 @@ -package memfs +package memwh import ( "bytes" diff --git a/fs/memfs/file_test.go b/fs/memwh/file_test.go similarity index 98% rename from fs/memfs/file_test.go rename to fs/memwh/file_test.go index e2f4231..d625a99 100644 --- a/fs/memfs/file_test.go +++ b/fs/memwh/file_test.go @@ -1,4 +1,4 @@ -package memfs +package memwh // func Test_File_Read_Memory(t *testing.T) { // r := require.New(t) diff --git a/fs/memwh/http.go b/fs/memwh/http.go new file mode 100644 index 0000000..a9be616 --- /dev/null +++ b/fs/memwh/http.go @@ -0,0 +1 @@ +package memwh diff --git a/fs/memfs/http_test.go b/fs/memwh/http_test.go similarity index 99% rename from fs/memfs/http_test.go rename to fs/memwh/http_test.go index ba0f237..9a9ed14 100644 --- a/fs/memfs/http_test.go +++ b/fs/memwh/http_test.go @@ -1,4 +1,4 @@ -package memfs +package memwh // func Test_HTTP_Dir(t *testing.T) { // r := require.New(t) diff --git a/fs/memfs/json.go b/fs/memwh/json.go similarity index 98% rename from fs/memfs/json.go rename to fs/memwh/json.go index 31bb74d..8557cc3 100644 --- a/fs/memfs/json.go +++ b/fs/memwh/json.go @@ -1,4 +1,4 @@ -package memfs +package memwh import ( "encoding/json" diff --git a/fs/memfs/json_test.go b/fs/memwh/json_test.go similarity index 97% rename from fs/memfs/json_test.go rename to fs/memwh/json_test.go index c257cc2..7b0b9c1 100644 --- a/fs/memfs/json_test.go +++ b/fs/memwh/json_test.go @@ -1,4 +1,4 @@ -package memfs +package memwh // func Test_File_JSON(t *testing.T) { // r := require.New(t) diff --git a/fs/memfs/memfs.go b/fs/memwh/memfs.go similarity index 99% rename from fs/memfs/memfs.go rename to fs/memwh/memfs.go index 537cf82..a8d9cbb 100644 --- a/fs/memfs/memfs.go +++ b/fs/memwh/memfs.go @@ -1,4 +1,4 @@ -package memfs +package memwh import ( "fmt" diff --git a/fs/memfs/memfs_test.go b/fs/memwh/memfs_test.go similarity index 96% rename from fs/memfs/memfs_test.go rename to fs/memwh/memfs_test.go index cd27931..be388e4 100644 --- a/fs/memfs/memfs_test.go +++ b/fs/memwh/memfs_test.go @@ -1,4 +1,4 @@ -package memfs +package memwh import ( "testing" diff --git a/fs/memfs/mkdirall.go b/fs/memwh/mkdirall.go similarity index 98% rename from fs/memfs/mkdirall.go rename to fs/memwh/mkdirall.go index 1cd5c43..9694f9b 100644 --- a/fs/memfs/mkdirall.go +++ b/fs/memwh/mkdirall.go @@ -1,4 +1,4 @@ -package memfs +package memwh import ( "os" diff --git a/fs/memfs/mkdirall_test.go b/fs/memwh/mkdirall_test.go similarity index 96% rename from fs/memfs/mkdirall_test.go rename to fs/memwh/mkdirall_test.go index a9da153..6759585 100644 --- a/fs/memfs/mkdirall_test.go +++ b/fs/memwh/mkdirall_test.go @@ -1,4 +1,4 @@ -package memfs +package memwh import ( "os" diff --git a/fs/memfs/open.go b/fs/memwh/open.go similarity index 97% rename from fs/memfs/open.go rename to fs/memwh/open.go index 78f27d6..4304218 100644 --- a/fs/memfs/open.go +++ b/fs/memwh/open.go @@ -1,4 +1,4 @@ -package memfs +package memwh import ( "fmt" diff --git a/fs/memfs/open_test.go b/fs/memwh/open_test.go similarity index 97% rename from fs/memfs/open_test.go rename to fs/memwh/open_test.go index 4442bd5..5ffa5b9 100644 --- a/fs/memfs/open_test.go +++ b/fs/memwh/open_test.go @@ -1,4 +1,4 @@ -package memfs +package memwh // func Test_Open(t *testing.T) { // r := require.New(t) diff --git a/fs/memfs/stat.go b/fs/memwh/stat.go similarity index 94% rename from fs/memfs/stat.go rename to fs/memwh/stat.go index 0e9fc6f..404095e 100644 --- a/fs/memfs/stat.go +++ b/fs/memwh/stat.go @@ -1,4 +1,4 @@ -package memfs +package memwh import ( "fmt" diff --git a/fs/memfs/stat_test.go b/fs/memwh/stat_test.go similarity index 96% rename from fs/memfs/stat_test.go rename to fs/memwh/stat_test.go index 492c41c..0a6951b 100644 --- a/fs/memfs/stat_test.go +++ b/fs/memwh/stat_test.go @@ -1,4 +1,4 @@ -package memfs +package memwh // func Test_Stat(t *testing.T) { // r := require.New(t) diff --git a/fs/memfs/walk.go b/fs/memwh/walk.go similarity index 97% rename from fs/memfs/walk.go rename to fs/memwh/walk.go index 015acd5..93d3538 100644 --- a/fs/memfs/walk.go +++ b/fs/memwh/walk.go @@ -1,4 +1,4 @@ -package memfs +package memwh import ( "fmt" diff --git a/fs/memfs/walk_test.go b/fs/memwh/walk_test.go similarity index 98% rename from fs/memfs/walk_test.go rename to fs/memwh/walk_test.go index 179368a..49849a7 100644 --- a/fs/memfs/walk_test.go +++ b/fs/memwh/walk_test.go @@ -1,4 +1,4 @@ -package memfs +package memwh // func Test_Walk(t *testing.T) { // r := require.New(t) diff --git a/fs/mod_time.go b/fs/mod_time.go new file mode 100644 index 0000000..b715106 --- /dev/null +++ b/fs/mod_time.go @@ -0,0 +1,24 @@ +package fs + +import ( + "encoding/json" + "time" +) + +const timeFmt = time.RFC3339Nano + +type ModTime time.Time + +func (m ModTime) MarshalJSON() ([]byte, error) { + t := time.Time(m) + return json.Marshal(t.Format(timeFmt)) +} + +func (m *ModTime) UnmarshalJSON(b []byte) error { + t := time.Time{} + if err := json.Unmarshal(b, &t); err != nil { + return err + } + (*m) = ModTime(t) + return nil +} diff --git a/fs/fs.go b/fs/warehouse.go similarity index 100% rename from fs/fs.go rename to fs/warehouse.go