Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: stdio - add some commonly io interface definition
- Loading branch information
Showing
5 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package jsonutil | ||
|
||
/* | ||
TODO json build | ||
type JsonBuilder struct { | ||
Indent string | ||
// mu sync.Mutex | ||
// cfg *CConfig | ||
buf bytes.Buffer | ||
out io.Writer | ||
} | ||
// AddField add field to json | ||
func (b *JsonBuilder) AddField(key string, value any) *JsonBuilder { | ||
b.buf.WriteString(`,"`) | ||
b.buf.WriteString(key) | ||
b.buf.WriteString(`":`) | ||
b.encode(value) | ||
return b | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package stdio | ||
|
||
import "io" | ||
|
||
// Flusher interface | ||
type Flusher interface { | ||
Flush() error | ||
} | ||
|
||
// FlushWriter is the interface satisfied by logging destinations. | ||
type FlushWriter interface { | ||
Flusher | ||
// Writer the output writer | ||
io.Writer | ||
} | ||
|
||
// FlushCloseWriter is the interface satisfied by logging destinations. | ||
type FlushCloseWriter interface { | ||
Flusher | ||
// WriteCloser the output writer | ||
io.WriteCloser | ||
} | ||
|
||
// SyncCloseWriter is the interface satisfied by logging destinations. | ||
// such as os.File | ||
type SyncCloseWriter interface { | ||
Flusher | ||
// WriteCloser the output writer | ||
io.WriteCloser | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters