From 9f1650927ed100fdd3b317f660b596deee4c2333 Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Wed, 14 Dec 2022 09:49:55 -0800 Subject: [PATCH] initial commits --- content.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/content.go b/content.go index a7286e4..5a7316c 100644 --- a/content.go +++ b/content.go @@ -21,6 +21,7 @@ import ( // FileModTIme: time.Date(2022, 12, 12, 10, 30, 14, 2, time.UTC), // } type Content struct{ + value string reader io.Reader size int64 closed bool @@ -41,11 +42,12 @@ var _ io.ReadCloser = &Content{} // FileName: "message.md", // FileModTIme: time.Now(), // } -func CreateContent(s string) Content { - var reader io.Reader = strings.NewReader(s) - var size int64 = int64(len(s)) +func CreateContent(value string) Content { + var reader io.Reader = strings.NewReader(value) + var size int64 = int64(len(value)) return Content{ + value:value, reader:reader, size:size, } @@ -155,3 +157,14 @@ func (receiver *Content) Size() int64 { return receiver.size } + +// String retusn the value of the string that strfs.Content is wrapping. +// +// String makes *strfs.Content fit the fmt.Stringer interface. +func (receiver *Content) String() string { + if nil == receiver { + return "" + } + + return receiver.value +}