Browse Source

lib/fs: Use os.FileMode.String for fs.FileMode (#5302)

Simon Frei 7 năm trước cách đây
mục cha
commit
53b0f36be6
2 tập tin đã thay đổi với 12 bổ sung0 xóa
  1. 4 0
      lib/fs/filesystem.go
  2. 8 0
      lib/fs/filesystem_test.go

+ 4 - 0
lib/fs/filesystem.go

@@ -79,6 +79,10 @@ type FileInfo interface {
 // FileMode is similar to os.FileMode
 type FileMode uint32
 
+func (fm FileMode) String() string {
+	return os.FileMode(fm).String()
+}
+
 // Usage represents filesystem space usage
 type Usage struct {
 	Free  int64

+ 8 - 0
lib/fs/filesystem_test.go

@@ -98,3 +98,11 @@ func TestCanonicalize(t *testing.T) {
 		}
 	}
 }
+
+func TestFileModeString(t *testing.T) {
+	var fm FileMode = 0777
+	exp := "-rwxrwxrwx"
+	if fm.String() != exp {
+		t.Fatalf("Got %v, expected %v", fm.String(), exp)
+	}
+}