Use new gofumpt (#21613)

Update tinylib. Should fix CI.

`gofumpt -w .&&go generate ./...`
This commit is contained in:
Klaus Post
2025-09-28 22:59:21 +02:00
committed by GitHub
parent 456d9462e5
commit b8631cf531
171 changed files with 881 additions and 899 deletions

View File

@@ -86,40 +86,40 @@ func Parse(arnStr string) (arn ARN, err error) {
ps := strings.Split(arnStr, ":")
if len(ps) != 6 || ps[0] != string(arnPrefixArn) {
err = errors.New("invalid ARN string format")
return
return arn, err
}
if ps[1] != string(arnPartitionMinio) {
err = errors.New("invalid ARN - bad partition field")
return
return arn, err
}
if ps[2] != string(arnServiceIAM) {
err = errors.New("invalid ARN - bad service field")
return
return arn, err
}
// ps[3] is region and is not validated here. If the region is invalid,
// the ARN would not match any configured ARNs in the server.
if ps[4] != "" {
err = errors.New("invalid ARN - unsupported account-id field")
return
return arn, err
}
res := strings.SplitN(ps[5], "/", 2)
if len(res) != 2 {
err = errors.New("invalid ARN - resource does not contain a \"/\"")
return
return arn, err
}
if res[0] != string(arnResourceTypeRole) {
err = errors.New("invalid ARN: resource type is invalid")
return
return arn, err
}
if !validResourceIDRegex.MatchString(res[1]) {
err = fmt.Errorf("invalid resource ID: %s", res[1])
return
return arn, err
}
arn = ARN{
@@ -129,5 +129,5 @@ func Parse(arnStr string) (arn ARN, err error) {
ResourceType: arnResourceTypeRole,
ResourceID: res[1],
}
return
return arn, err
}

View File

@@ -67,7 +67,7 @@ func (bp *BytePoolCap) Get() (b []byte) {
// create new aligned buffer
b = reedsolomon.AllocAligned(1, bp.wcap)[0][:bp.w]
}
return
return b
}
// Put returns the given Buffer to the BytePool.

View File

@@ -1,7 +1,7 @@
package bandwidth
// Code generated by github.com/tinylib/msgp DO NOT EDIT.
package bandwidth
import (
"github.com/tinylib/msgp/msgp"
)

View File

@@ -1,7 +1,7 @@
package bandwidth
// Code generated by github.com/tinylib/msgp DO NOT EDIT.
package bandwidth
import (
"bytes"
"testing"

View File

@@ -52,7 +52,7 @@ func (r *MonitoredReader) Read(buf []byte) (n int, err error) {
}
if r.lastErr != nil {
err = r.lastErr
return
return n, err
}
b := r.throttle.Burst() // maximum available tokens
need := len(buf) // number of bytes requested by caller
@@ -81,15 +81,15 @@ func (r *MonitoredReader) Read(buf []byte) (n int, err error) {
}
err = r.throttle.WaitN(r.ctx, tokens)
if err != nil {
return
return n, err
}
n, err = r.r.Read(buf[:need])
if err != nil {
r.lastErr = err
return
return n, err
}
r.m.updateMeasurement(r.opts.BucketOptions, uint64(tokens))
return
return n, err
}
// NewMonitoredReader returns reference to a monitored reader that throttles reads to configured bandwidth for the

View File

@@ -587,7 +587,7 @@ func ParseObjectLegalHold(reader io.Reader) (hold *ObjectLegalHold, err error) {
if !hold.Status.Valid() {
return nil, ErrMalformedXML
}
return
return hold, err
}
// FilterObjectLockMetadata filters object lock metadata if s3:GetObjectRetention permission is denied or if isCopy flag set.

View File

@@ -1,7 +1,7 @@
package replication
// Code generated by github.com/tinylib/msgp DO NOT EDIT.
package replication
import (
"github.com/tinylib/msgp/msgp"
)

View File

@@ -1,3 +1,3 @@
package replication
// Code generated by github.com/tinylib/msgp DO NOT EDIT.
package replication

View File

@@ -453,7 +453,7 @@ func ParseConfigTargetID(r io.Reader) (ids map[string]bool, err error) {
if err := scanner.Err(); err != nil {
return nil, err
}
return
return ids, err
}
// ReadConfig - read content from input and write into c.
@@ -578,7 +578,7 @@ var validSiteNameRegex = regexp.MustCompile("^[a-z][a-z0-9-]+$")
// region sub-system as well.
func LookupSite(siteKV KVS, regionKV KVS) (s Site, err error) {
if err = CheckValidKeys(SiteSubSys, siteKV, DefaultSiteKVS); err != nil {
return
return s, err
}
region := env.Get(EnvRegion, "")
if region == "" {
@@ -596,7 +596,7 @@ func LookupSite(siteKV KVS, regionKV KVS) (s Site, err error) {
// is legacy, we return an error to tell the user to
// reset the region via the new command.
err = Errorf("could not load region from legacy configuration as it was invalid - use 'mc admin config set myminio site region=myregion name=myname' to set a region and name (%v)", err)
return
return s, err
}
region = regionKV.Get(RegionName)
@@ -606,7 +606,7 @@ func LookupSite(siteKV KVS, regionKV KVS) (s Site, err error) {
err = Errorf(
"region '%s' is invalid, expected simple characters such as [us-east-1, myregion...]",
region)
return
return s, err
}
s.region = region
}
@@ -617,11 +617,11 @@ func LookupSite(siteKV KVS, regionKV KVS) (s Site, err error) {
err = Errorf(
"site name '%s' is invalid, expected simple characters such as [cal-rack0, myname...]",
name)
return
return s, err
}
s.name = name
}
return
return s, err
}
// CheckValidKeys - checks if inputs KVS has the necessary keys,
@@ -1196,13 +1196,13 @@ func (c Config) ResolveConfigParam(subSys, target, cfgParam string, redactSecret
// Initially only support OpenID
if !resolvableSubsystems.Contains(subSys) {
return
return value, cs, isRedacted
}
// Check if config param requested is valid.
defKVS, ok := DefaultKVS[subSys]
if !ok {
return
return value, cs, isRedacted
}
defValue, isFound := defKVS.Lookup(cfgParam)
@@ -1211,7 +1211,7 @@ func (c Config) ResolveConfigParam(subSys, target, cfgParam string, redactSecret
defValue, isFound = "", true
}
if !isFound {
return
return value, cs, isRedacted
}
if target == "" {
@@ -1236,7 +1236,7 @@ func (c Config) ResolveConfigParam(subSys, target, cfgParam string, redactSecret
value = env.Get(envVar, "")
if value != "" {
cs = ValueSourceEnv
return
return value, cs, isRedacted
}
// Lookup config store.
@@ -1246,7 +1246,7 @@ func (c Config) ResolveConfigParam(subSys, target, cfgParam string, redactSecret
value, ok3 = kvs.Lookup(cfgParam)
if ok3 {
cs = ValueSourceCfg
return
return value, cs, isRedacted
}
}
}
@@ -1254,7 +1254,7 @@ func (c Config) ResolveConfigParam(subSys, target, cfgParam string, redactSecret
// Return the default value.
value = defValue
cs = ValueSourceDef
return
return value, cs, isRedacted
}
// KVSrc represents a configuration parameter key and value along with the

View File

@@ -98,7 +98,7 @@ func (ssec) ParseHTTP(h http.Header) (key [32]byte, err error) {
func (s3 ssec) UnsealObjectKey(h http.Header, metadata map[string]string, bucket, object string) (key ObjectKey, err error) {
clientKey, err := s3.ParseHTTP(h)
if err != nil {
return
return key, err
}
return unsealObjectKey(clientKey[:], metadata, bucket, object)
}

View File

@@ -81,7 +81,7 @@ func Requested(h http.Header) bool {
func (sse ssecCopy) UnsealObjectKey(h http.Header, metadata map[string]string, bucket, object string) (key ObjectKey, err error) {
clientKey, err := sse.ParseHTTP(h)
if err != nil {
return
return key, err
}
return unsealObjectKey(clientKey[:], metadata, bucket, object)
}
@@ -91,10 +91,10 @@ func (sse ssecCopy) UnsealObjectKey(h http.Header, metadata map[string]string, b
func unsealObjectKey(clientKey []byte, metadata map[string]string, bucket, object string) (key ObjectKey, err error) {
sealedKey, err := SSEC.ParseMetadata(metadata)
if err != nil {
return
return key, err
}
err = key.Unseal(clientKey, sealedKey, SSEC.String(), bucket, object)
return
return key, err
}
// EncryptSinglePart encrypts an io.Reader which must be the

View File

@@ -146,7 +146,7 @@ func readDriveStats(statsFile string) (iostats IOStats, err error) {
iostats.DiscardSectors = stats[13]
iostats.DiscardTicks = stats[14]
}
return
return iostats, err
}
func readStat(fileName string) (stats []uint64, err error) {

View File

@@ -69,7 +69,7 @@ func testSimpleWriteLock(t *testing.T, duration time.Duration) (locked bool) {
drwm3.Unlock(t.Context())
}
// fmt.Println("Write lock failed due to timeout")
return
return locked
}
func TestSimpleWriteLockAcquired(t *testing.T) {
@@ -116,7 +116,7 @@ func testDualWriteLock(t *testing.T, duration time.Duration) (locked bool) {
drwm2.Unlock(t.Context())
}
// fmt.Println("2nd write lock failed due to timeout")
return
return locked
}
func TestDualWriteLockAcquired(t *testing.T) {

View File

@@ -1,7 +1,7 @@
package dsync
// Code generated by github.com/tinylib/msgp DO NOT EDIT.
package dsync
import (
"github.com/tinylib/msgp/msgp"
)

View File

@@ -1,7 +1,7 @@
package dsync
// Code generated by github.com/tinylib/msgp DO NOT EDIT.
package dsync
import (
"bytes"
"testing"

View File

@@ -33,7 +33,7 @@ func (r *lockedRandSource) Int63() (n int64) {
r.lk.Lock()
n = r.src.Int63()
r.lk.Unlock()
return
return n
}
// Seed uses the provided seed value to initialize the generator to a

View File

@@ -81,13 +81,13 @@ func getESVersionSupportStatus(version string) (res ESSupportStatus, err error)
parts := strings.Split(version, ".")
if len(parts) < 1 {
err = fmt.Errorf("bad ES version string: %s", version)
return
return res, err
}
majorVersion, err := strconv.Atoi(parts[0])
if err != nil {
err = fmt.Errorf("bad ES version string: %s", version)
return
return res, err
}
switch {
@@ -96,7 +96,7 @@ func getESVersionSupportStatus(version string) (res ESSupportStatus, err error)
default:
res = ESSSupported
}
return
return res, err
}
// magic HH-256 key as HH-256 hash of the first 100 decimals of π as utf-8 string with a zero key.

View File

@@ -77,7 +77,7 @@ func (x *XDGSCRAMClient) Begin(userName, password, authzID string) (err error) {
// completes is also an error.
func (x *XDGSCRAMClient) Step(challenge string) (response string, err error) {
response, err = x.ClientConversation.Step(challenge)
return
return response, err
}
// Done returns true if the conversation is completed or has errored.

View File

@@ -154,7 +154,7 @@ func getHosts(n int) (hosts []string, listeners []net.Listener, err error) {
hosts = append(hosts, "http://"+addr.String())
listeners = append(listeners, l)
}
return
return hosts, listeners, err
}
func startHTTPServer(listener net.Listener, handler http.Handler) (server *httptest.Server) {

View File

@@ -1,7 +1,7 @@
package grid
// Code generated by github.com/tinylib/msgp DO NOT EDIT.
package grid
import (
"github.com/tinylib/msgp/msgp"
)

View File

@@ -1,7 +1,7 @@
package grid
// Code generated by github.com/tinylib/msgp DO NOT EDIT.
package grid
import (
"github.com/tinylib/msgp/msgp"
)

View File

@@ -1,7 +1,7 @@
package grid
// Code generated by github.com/tinylib/msgp DO NOT EDIT.
package grid
import (
"bytes"
"testing"

View File

@@ -623,7 +623,7 @@ func (m *muxClient) addResponse(r Response) (ok bool) {
default:
if m.stateless {
// Drop message if not stateful.
return
return ok
}
err := errors.New("INTERNAL ERROR: Response was blocked")
gridLogIf(m.ctx, err)

View File

@@ -74,7 +74,7 @@ func (m *MSS) UnmarshalMsg(bts []byte) (o []byte, err error) {
zb0002, bts, err = msgp.ReadMapHeaderBytes(bts)
if err != nil {
err = msgp.WrapError(err, "Values")
return
return o, err
}
dst := *m
if dst == nil {
@@ -91,12 +91,12 @@ func (m *MSS) UnmarshalMsg(bts []byte) (o []byte, err error) {
za0001, bts, err = msgp.ReadStringBytes(bts)
if err != nil {
err = msgp.WrapError(err, "Values")
return
return o, err
}
za0002, bts, err = msgp.ReadStringBytes(bts)
if err != nil {
err = msgp.WrapError(err, "Values", za0001)
return
return o, err
}
dst[za0001] = za0002
}
@@ -329,7 +329,7 @@ func (u URLValues) MarshalMsg(b []byte) (o []byte, err error) {
o = msgp.AppendString(o, zb0007[zb0008])
}
}
return
return o, err
}
// UnmarshalMsg implements msgp.Unmarshaler
@@ -338,7 +338,7 @@ func (u *URLValues) UnmarshalMsg(bts []byte) (o []byte, err error) {
zb0004, bts, err = msgp.ReadMapHeaderBytes(bts)
if err != nil {
err = msgp.WrapError(err)
return
return o, err
}
if *u == nil {
*u = urlValuesPool.Get()
@@ -356,13 +356,13 @@ func (u *URLValues) UnmarshalMsg(bts []byte) (o []byte, err error) {
zb0001, bts, err = msgp.ReadStringBytes(bts)
if err != nil {
err = msgp.WrapError(err)
return
return o, err
}
var zb0005 uint32
zb0005, bts, err = msgp.ReadArrayHeaderBytes(bts)
if err != nil {
err = msgp.WrapError(err, zb0001)
return
return o, err
}
if cap(zb0002) >= int(zb0005) {
zb0002 = zb0002[:zb0005]
@@ -373,13 +373,13 @@ func (u *URLValues) UnmarshalMsg(bts []byte) (o []byte, err error) {
zb0002[zb0003], bts, err = msgp.ReadStringBytes(bts)
if err != nil {
err = msgp.WrapError(err, zb0001, zb0003)
return
return o, err
}
}
(*u)[zb0001] = zb0002
}
o = bts
return
return o, err
}
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
@@ -393,7 +393,7 @@ func (u URLValues) Msgsize() (s int) {
}
}
return
return s
}
// JSONPool is a pool for JSON objects that unmarshal into T.

View File

@@ -75,6 +75,6 @@ func DialContextWithLookupHost(lookupHost LookupHost, baseDialCtx DialContext) D
}
}
return
return conn, err
}
}

View File

@@ -172,7 +172,7 @@ func newHTTPListener(ctx context.Context, serverAddrs []string, opts TCPOptions)
if len(listeners) == 0 {
// No listeners initialized, no need to continue
return
return listener, listenErrs
}
listeners = slices.Clip(listeners)
@@ -187,5 +187,5 @@ func newHTTPListener(ctx context.Context, serverAddrs []string, opts TCPOptions)
opts.Trace(fmt.Sprintf("opening %d listeners", len(listener.listeners)))
listener.start()
return
return listener, listenErrs
}

View File

@@ -132,7 +132,7 @@ func (srv *Server) Init(listenCtx context.Context, listenErrCallback func(listen
return srv.Serve(l)
}
return
return serve, err
}
// Shutdown - shuts down HTTP server.

View File

@@ -52,5 +52,5 @@ func (l *HardLimitedReader) Read(p []byte) (n int, err error) {
if l.N < 0 {
return 0, ErrOverread
}
return
return n, err
}

View File

@@ -271,7 +271,7 @@ func (c *MapClaims) Lookup(key string) (value string, ok bool) {
if ok {
value, ok = vinterface.(string)
}
return
return value, ok
}
// SetExpiry sets expiry in unix epoch secs

View File

@@ -257,5 +257,5 @@ func lockFileEx(h syscall.Handle, flags, locklow, lockhigh uint32, ol *syscall.O
err = syscall.EINVAL
}
}
return
return err
}

View File

@@ -178,7 +178,7 @@ func (h *Target) initQueueStore(ctx context.Context) (err error) {
h.store = queueStore
h.storeCtxCancel = cancel
store.StreamItems(h.store, h, ctx.Done(), h.kconfig.LogOnce)
return
return err
}
func (h *Target) startKafkaLogger() {
@@ -355,7 +355,7 @@ func (h *Target) SendFromStore(key store.Key) (err error) {
err = h.send(auditEntry)
if err != nil {
atomic.AddInt64(&h.failedMessages, 1)
return
return err
}
// Delete the event from store.
return h.store.Del(key)

View File

@@ -78,7 +78,7 @@ func (x *XDGSCRAMClient) Begin(userName, password, authzID string) (err error) {
// completes is also an error.
func (x *XDGSCRAMClient) Step(challenge string) (response string, err error) {
response, err = x.ClientConversation.Step(challenge)
return
return response, err
}
// Done returns true if the conversation is completed or has errored.

View File

@@ -170,7 +170,7 @@ func splitTargets(targets []Target, t types.TargetType) (group1 []Target, group2
group2 = append(group2, target)
}
}
return
return group1, group2
}
func cancelTargets(targets []Target) {

View File

@@ -65,7 +65,7 @@ func testSimpleWriteLock(t *testing.T, duration time.Duration) (locked bool) {
} else {
t.Log("Write lock failed due to timeout")
}
return
return locked
}
func TestSimpleWriteLockAcquired(t *testing.T) {
@@ -111,7 +111,7 @@ func testDualWriteLock(t *testing.T, duration time.Duration) (locked bool) {
} else {
t.Log("2nd write lock failed due to timeout")
}
return
return locked
}
func TestDualWriteLockAcquired(t *testing.T) {

View File

@@ -210,13 +210,13 @@ type respBodyMonitor struct {
func (r *respBodyMonitor) Read(p []byte) (n int, err error) {
n, err = r.ReadCloser.Read(p)
r.errorStatus(err)
return
return n, err
}
func (r *respBodyMonitor) Close() (err error) {
err = r.ReadCloser.Close()
r.errorStatus(err)
return
return err
}
func (r *respBodyMonitor) errorStatus(err error) {

View File

@@ -196,7 +196,7 @@ func (r *RingBuffer) read(p []byte) (n int, err error) {
n = min(r.w-r.r, len(p))
copy(p, r.buf[r.r:r.r+n])
r.r = (r.r + n) % r.size
return
return n, err
}
n = min(r.size-r.r+r.w, len(p))

View File

@@ -79,7 +79,7 @@ func (e *SelectExpression) analyze(s *Select) (result qProp) {
for _, ex := range e.Expressions {
result.combine(ex.analyze(s))
}
return
return result
}
func (e *AliasedExpression) analyze(s *Select) qProp {
@@ -90,14 +90,14 @@ func (e *Expression) analyze(s *Select) (result qProp) {
for _, ac := range e.And {
result.combine(ac.analyze(s))
}
return
return result
}
func (e *AndCondition) analyze(s *Select) (result qProp) {
for _, ac := range e.Condition {
result.combine(ac.analyze(s))
}
return
return result
}
func (e *Condition) analyze(s *Select) (result qProp) {
@@ -106,14 +106,14 @@ func (e *Condition) analyze(s *Select) (result qProp) {
} else {
result = e.Not.analyze(s)
}
return
return result
}
func (e *ListExpr) analyze(s *Select) (result qProp) {
for _, ac := range e.Elements {
result.combine(ac.analyze(s))
}
return
return result
}
func (e *ConditionOperand) analyze(s *Select) (result qProp) {
@@ -123,7 +123,7 @@ func (e *ConditionOperand) analyze(s *Select) (result qProp) {
result.combine(e.Operand.analyze(s))
result.combine(e.ConditionRHS.analyze(s))
}
return
return result
}
func (e *ConditionRHS) analyze(s *Select) (result qProp) {
@@ -143,7 +143,7 @@ func (e *ConditionRHS) analyze(s *Select) (result qProp) {
default:
result = qProp{err: errUnexpectedInvalidNode}
}
return
return result
}
func (e *In) analyze(s *Select) (result qProp) {
@@ -153,7 +153,7 @@ func (e *In) analyze(s *Select) (result qProp) {
if len(e.JPathExpr.PathExpr) > 0 {
if e.JPathExpr.BaseKey.String() != s.From.As && !strings.EqualFold(e.JPathExpr.BaseKey.String(), baseTableName) {
result = qProp{err: errInvalidKeypath}
return
return result
}
}
result = qProp{isRowFunc: true}
@@ -162,7 +162,7 @@ func (e *In) analyze(s *Select) (result qProp) {
default:
result = qProp{err: errUnexpectedInvalidNode}
}
return
return result
}
func (e *Operand) analyze(s *Select) (result qProp) {
@@ -170,7 +170,7 @@ func (e *Operand) analyze(s *Select) (result qProp) {
for _, r := range e.Right {
result.combine(r.Right.analyze(s))
}
return
return result
}
func (e *MultOp) analyze(s *Select) (result qProp) {
@@ -178,7 +178,7 @@ func (e *MultOp) analyze(s *Select) (result qProp) {
for _, r := range e.Right {
result.combine(r.Right.analyze(s))
}
return
return result
}
func (e *UnaryTerm) analyze(s *Select) (result qProp) {
@@ -187,7 +187,7 @@ func (e *UnaryTerm) analyze(s *Select) (result qProp) {
} else {
result = e.Primary.analyze(s)
}
return
return result
}
func (e *PrimaryTerm) analyze(s *Select) (result qProp) {
@@ -200,7 +200,7 @@ func (e *PrimaryTerm) analyze(s *Select) (result qProp) {
if len(e.JPathExpr.PathExpr) > 0 {
if e.JPathExpr.BaseKey.String() != s.From.As && !strings.EqualFold(e.JPathExpr.BaseKey.String(), baseTableName) {
result = qProp{err: errInvalidKeypath}
return
return result
}
}
result = qProp{isRowFunc: true}
@@ -217,7 +217,7 @@ func (e *PrimaryTerm) analyze(s *Select) (result qProp) {
default:
result = qProp{err: errUnexpectedInvalidNode}
}
return
return result
}
func (e *FuncExpr) analyze(s *Select) (result qProp) {

View File

@@ -91,7 +91,7 @@ func (e *FuncExpr) evalSQLFnNode(r Record, tableAlias string) (res *Value, err e
case sqlFnCast:
expr := e.Cast.Expr
res, err = expr.castTo(r, strings.ToUpper(e.Cast.CastType), tableAlias)
return
return res, err
case sqlFnSubstring:
return handleSQLSubstring(r, e.Substring, tableAlias)

View File

@@ -57,7 +57,7 @@ func ParseSelectStatement(s string) (stmt SelectStatement, err error) {
err = SQLParser.ParseString(s, &selectAST)
if err != nil {
err = errQueryParseFailure(err)
return
return stmt, err
}
// Check if select is "SELECT s.* from S3Object s"
@@ -80,7 +80,7 @@ func ParseSelectStatement(s string) (stmt SelectStatement, err error) {
stmt.limitValue, err = parseLimit(selectAST.Limit)
if err != nil {
err = errQueryAnalysisFailure(err)
return
return stmt, err
}
// Analyze where clause
@@ -88,19 +88,19 @@ func ParseSelectStatement(s string) (stmt SelectStatement, err error) {
whereQProp := selectAST.Where.analyze(&selectAST)
if whereQProp.err != nil {
err = errQueryAnalysisFailure(fmt.Errorf("Where clause error: %w", whereQProp.err))
return
return stmt, err
}
if whereQProp.isAggregation {
err = errQueryAnalysisFailure(errors.New("WHERE clause cannot have an aggregation"))
return
return stmt, err
}
}
// Validate table name
err = validateTableName(selectAST.From)
if err != nil {
return
return stmt, err
}
// Analyze main select expression
@@ -120,7 +120,7 @@ func ParseSelectStatement(s string) (stmt SelectStatement, err error) {
}
}
}
return
return stmt, err
}
func validateTableName(from *TableExpression) error {

View File

@@ -46,7 +46,7 @@ func parseSQLTimestamp(s string) (t time.Time, err error) {
break
}
}
return
return t, err
}
// FormatSQLTimestamp - returns the a string representation of the

View File

@@ -175,13 +175,13 @@ func (v Value) ToFloat() (val float64, ok bool) {
// ToInt returns the value if int.
func (v Value) ToInt() (val int64, ok bool) {
val, ok = v.value.(int64)
return
return val, ok
}
// ToString returns the value if string.
func (v Value) ToString() (val string, ok bool) {
val, ok = v.value.(string)
return
return val, ok
}
// Equals returns whether the values strictly match.
@@ -220,25 +220,25 @@ func (v Value) SameTypeAs(b Value) (ok bool) {
// conversion succeeded.
func (v Value) ToBool() (val bool, ok bool) {
val, ok = v.value.(bool)
return
return val, ok
}
// ToTimestamp returns the timestamp value if present.
func (v Value) ToTimestamp() (t time.Time, ok bool) {
t, ok = v.value.(time.Time)
return
return t, ok
}
// ToBytes returns the value if byte-slice.
func (v Value) ToBytes() (val []byte, ok bool) {
val, ok = v.value.([]byte)
return
return val, ok
}
// ToArray returns the value if it is a slice of values.
func (v Value) ToArray() (val []Value, ok bool) {
val, ok = v.value.([]Value)
return
return val, ok
}
// IsNull - checks if value is missing.
@@ -393,7 +393,7 @@ func (v *Value) InferBytesType() (err error) {
}
// Fallback to string
v.setString(asString)
return
return err
}
// When numeric types are compared, type promotions could happen. If

View File

@@ -151,7 +151,7 @@ func (store *QueueStore[I]) multiWrite(key Key, items []I) (err error) {
// Increment the item count.
store.entries[key.String()] = time.Now().UnixNano()
return
return err
}
// write - writes an item to the directory.
@@ -235,7 +235,7 @@ func (store *QueueStore[I]) GetRaw(key Key) (raw []byte, err error) {
raw, err = os.ReadFile(filepath.Join(store.directory, key.String()))
if err != nil {
return
return raw, err
}
if len(raw) == 0 {
@@ -246,7 +246,7 @@ func (store *QueueStore[I]) GetRaw(key Key) (raw []byte, err error) {
raw, err = s2.Decode(nil, raw)
}
return
return raw, err
}
// Get - gets an item from the store.
@@ -274,7 +274,7 @@ func (store *QueueStore[I]) GetMultiple(key Key) (items []I, err error) {
items = append(items, item)
}
return
return items, err
}
// Del - Deletes an entry from the store.

View File

@@ -86,7 +86,7 @@ func getItemCount(k string) (count int, err error) {
if len(v) == 2 {
return strconv.Atoi(v[0])
}
return
return count, err
}
func parseKey(k string) (key Key) {
@@ -102,7 +102,7 @@ func parseKey(k string) (key Key) {
key.Extension = "." + vals[1]
key.Name = strings.TrimSuffix(key.Name, key.Extension)
}
return
return key
}
// replayItems - Reads the items from the store and replays.