Bump github.com/gookit/config/v2 from 2.2.2 to 2.2.3

Bumps [github.com/gookit/config/v2](https://github.com/gookit/config) from 2.2.2 to 2.2.3.
- [Release notes](https://github.com/gookit/config/releases)
- [Commits](https://github.com/gookit/config/compare/v2.2.2...v2.2.3)

---
updated-dependencies:
- dependency-name: github.com/gookit/config/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2023-08-30 13:10:31 +02:00
committed by Ralf Haferkamp
parent 69bd2c24a7
commit 0aafeccb93
20 changed files with 335 additions and 182 deletions
+89 -35
View File
@@ -3,12 +3,14 @@ package byteutil
import (
"bytes"
"fmt"
"strings"
)
// Buffer wrap and extends the bytes.Buffer
// Buffer wrap and extends the bytes.Buffer, add some useful methods
type Buffer struct {
bytes.Buffer
// custom error for testing
CloseErr error
FlushErr error
}
// NewBuffer instance
@@ -16,45 +18,87 @@ func NewBuffer() *Buffer {
return &Buffer{}
}
// WriteAny type value to buffer
func (b *Buffer) WriteAny(vs ...any) {
for _, v := range vs {
_, _ = b.Buffer.WriteString(fmt.Sprint(v))
}
}
// QuietWriteByte to buffer
func (b *Buffer) QuietWriteByte(c byte) {
// PrintByte to buffer, ignore error. alias of WriteByte()
func (b *Buffer) PrintByte(c byte) {
_ = b.WriteByte(c)
}
// QuietWritef write message to buffer
func (b *Buffer) QuietWritef(tpl string, vs ...any) {
// WriteStr1 quiet write one string to buffer
func (b *Buffer) WriteStr1(s string) {
b.writeStringNl(s, false)
}
// WriteStr1Nl quiet write one string and end with newline
func (b *Buffer) WriteStr1Nl(s string) {
b.writeStringNl(s, true)
}
// writeStringNl quiet write one string and end with newline
func (b *Buffer) writeStringNl(s string, nl bool) {
_, _ = b.Buffer.WriteString(s)
if nl {
_ = b.WriteByte('\n')
}
}
// WriteStr quiet write strings to buffer
func (b *Buffer) WriteStr(ss ...string) {
b.writeStringsNl(ss, false)
}
// WriteStrings to buffer, ignore error.
func (b *Buffer) WriteStrings(ss []string) {
b.writeStringsNl(ss, false)
}
// WriteStringNl write message to buffer and end with newline
func (b *Buffer) WriteStringNl(ss ...string) {
b.writeStringsNl(ss, true)
}
// writeStringsNl to buffer, ignore error.
func (b *Buffer) writeStringsNl(ss []string, nl bool) {
for _, s := range ss {
_, _ = b.Buffer.WriteString(s)
}
if nl {
_ = b.WriteByte('\n')
}
}
// WriteAny type value to buffer
func (b *Buffer) WriteAny(vs ...any) {
b.writeAnysWithNl(vs, false)
}
// Writeln write values to buffer and end with newline
func (b *Buffer) Writeln(vs ...any) {
b.writeAnysWithNl(vs, true)
}
// WriteAnyNl type value to buffer and end with newline
func (b *Buffer) WriteAnyNl(vs ...any) {
b.writeAnysWithNl(vs, true)
}
// WriteAnyLn type value to buffer and end with newline
func (b *Buffer) writeAnysWithNl(vs []any, nl bool) {
for _, v := range vs {
_, _ = b.Buffer.WriteString(fmt.Sprint(v))
}
if nl {
_ = b.WriteByte('\n')
}
}
// Printf quiet write message to buffer, ignore error.
func (b *Buffer) Printf(tpl string, vs ...any) {
_, _ = b.WriteString(fmt.Sprintf(tpl, vs...))
}
// Writeln write message to buffer with newline
func (b *Buffer) Writeln(ss ...string) {
b.QuietWriteln(ss...)
}
// QuietWriteln write message to buffer with newline
func (b *Buffer) QuietWriteln(ss ...string) {
_, _ = b.WriteString(strings.Join(ss, ""))
_ = b.WriteByte('\n')
}
// QuietWriteString to buffer
func (b *Buffer) QuietWriteString(ss ...string) {
_, _ = b.WriteString(strings.Join(ss, ""))
}
// MustWriteString to buffer
func (b *Buffer) MustWriteString(ss ...string) {
_, err := b.WriteString(strings.Join(ss, ""))
if err != nil {
panic(err)
}
// ResetGet buffer string. alias of ResetAndGet()
func (b *Buffer) ResetGet() string {
return b.ResetAndGet()
}
// ResetAndGet buffer string.
@@ -63,3 +107,13 @@ func (b *Buffer) ResetAndGet() string {
b.Reset()
return s
}
// Close buffer
func (b *Buffer) Close() error {
return b.CloseErr
}
// Flush buffer
func (b *Buffer) Flush() error {
return b.FlushErr
}