Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:rotating_light: Fix go vet errors on non-constant format strings and unkeyed struct fields

Danielb9a2370ef8d3
diff --git a/kernel/filesys/tree.go b/kernel/filesys/tree.go
index a5eb8c2755..3dc5644983 100644
--- a/kernel/filesys/tree.go
+++ b/kernel/filesys/tree.go
@@ -393,7 +393,7 @@ func WriteTree(tree *parse.Tree) (size uint64, err error) {
func writeTreeByWriteFile(filePath string, data []byte) (err error) {
if err = filelock.WriteFile(filePath, data); err != nil {
msg := fmt.Sprintf("write data [%s] failed: %s", filePath, err)
- logging.LogErrorf(msg)
+ logging.LogErrorf("%s", msg)
err = errors.New(msg)
return
}
diff --git a/kernel/mobile/kernel.go b/kernel/mobile/kernel.go
index 8da08c021d..f1517a03c1 100644
--- a/kernel/mobile/kernel.go
+++ b/kernel/mobile/kernel.go
@@ -68,21 +68,21 @@ func VerifyAppStoreTransaction(accountToken, transactionID string) (retCode int)
if "" == accountToken || "" == transactionID {
retCode = -6
retMsg = "invalid parameters"
- logging.LogErrorf(retMsg)
+ logging.LogErrorf("%s", retMsg)
return
}
if 36 != len(accountToken) {
retCode = -6
retMsg = fmt.Sprintf("invalid accountToken [%s]", accountToken)
- logging.LogErrorf(retMsg)
+ logging.LogErrorf("%s", retMsg)
return
}
if util.ContainerIOS != util.Container {
retCode = -3
retMsg = fmt.Sprintf("invalid container [%s]", util.Container)
- logging.LogErrorf(retMsg)
+ logging.LogErrorf("%s", retMsg)
return
}
@@ -90,7 +90,7 @@ func VerifyAppStoreTransaction(accountToken, transactionID string) (retCode int)
if nil == user || "" == user.UserToken {
retCode = -4
retMsg = "account not logged in"
- logging.LogErrorf(retMsg)
+ logging.LogErrorf("%s", retMsg)
return
}
@@ -98,7 +98,7 @@ func VerifyAppStoreTransaction(accountToken, transactionID string) (retCode int)
if "0" != cloudRegionArg && "1" != cloudRegionArg {
retCode = -1
retMsg = fmt.Sprintf("invalid cloud region [%s]", cloudRegionArg)
- logging.LogErrorf(retMsg)
+ logging.LogErrorf("%s", retMsg)
return
}
@@ -106,7 +106,7 @@ func VerifyAppStoreTransaction(accountToken, transactionID string) (retCode int)
if util.CurrentCloudRegion != cloudRegion {
retCode = -1
retMsg = fmt.Sprintf("invalid cloud region [cloudRegionArg=%s, currentRegion=%d]", cloudRegionArg, util.CurrentCloudRegion)
- logging.LogErrorf(retMsg)
+ logging.LogErrorf("%s", retMsg)
return
}
@@ -114,7 +114,7 @@ func VerifyAppStoreTransaction(accountToken, transactionID string) (retCode int)
if user.UserId != userID {
retCode = -5
retMsg = fmt.Sprintf("invalid user [userID=%s, accountToken=%s]", user.UserId, accountToken)
- logging.LogErrorf(retMsg)
+ logging.LogErrorf("%s", retMsg)
return
}
@@ -126,74 +126,74 @@ func VerifyAppStoreTransaction(accountToken, transactionID string) (retCode int)
if nil != reqErr {
retCode = -2
retMsg = fmt.Sprintf("verify app store transaction failed: %s", reqErr)
- logging.LogErrorf(retMsg)
+ logging.LogErrorf("%s", retMsg)
return
}
if http.StatusUnauthorized == resp.StatusCode || http.StatusForbidden == resp.StatusCode {
retCode = -4
retMsg = fmt.Sprintf("verify app store transaction failed [sc=%d]", resp.StatusCode)
- logging.LogErrorf(retMsg)
+ logging.LogErrorf("%s", retMsg)
return
}
if http.StatusOK != resp.StatusCode {
retCode = -2
retMsg = fmt.Sprintf("verify app store transaction failed [sc=%d]", resp.StatusCode)
- logging.LogErrorf(retMsg)
+ logging.LogErrorf("%s", retMsg)
return
}
if -1 == result.Code {
retCode = -5
retMsg = fmt.Sprintf("verify app store transaction failed [code=%d, msg=%s]", result.Code, result.Msg)
- logging.LogErrorf(retMsg)
+ logging.LogErrorf("%s", retMsg)
return
}
if -3 == result.Code {
retCode = -6
retMsg = fmt.Sprintf("verify app store transaction failed [code=%d, msg=%s]", result.Code, result.Msg)
- logging.LogErrorf(retMsg)
+ logging.LogErrorf("%s", retMsg)
return
}
if -2 == result.Code {
retCode = -8
retMsg = fmt.Sprintf("verify app store transaction failed [code=%d, msg=%s]", result.Code, result.Msg)
- logging.LogErrorf(retMsg)
+ logging.LogErrorf("%s", retMsg)
return
}
if -4 == result.Code {
retCode = -8
retMsg = fmt.Sprintf("verify app store transaction failed [code=%d, msg=%s]", result.Code, result.Msg)
- logging.LogErrorf(retMsg)
+ logging.LogErrorf("%s", retMsg)
return
}
if -5 == result.Code {
retCode = -7
retMsg = fmt.Sprintf("verify app store transaction failed [code=%d, msg=%s]", result.Code, result.Msg)
- logging.LogErrorf(retMsg)
+ logging.LogErrorf("%s", retMsg)
return
}
if -6 == result.Code {
retCode = -9
retMsg = fmt.Sprintf("verify app store transaction failed [code=%d, msg=%s]", result.Code, result.Msg)
- logging.LogErrorf(retMsg)
+ logging.LogErrorf("%s", retMsg)
return
}
if -64 == result.Code {
retCode = -2
retMsg = fmt.Sprintf("verify app store transaction failed [code=%d, msg=%s]", result.Code, result.Msg)
- logging.LogErrorf(retMsg)
+ logging.LogErrorf("%s", retMsg)
return
}
if 0 != result.Code {
retCode = -2
retMsg = fmt.Sprintf("verify app store transaction failed [code=%d, msg=%s]", result.Code, result.Msg)
- logging.LogErrorf(retMsg)
+ logging.LogErrorf("%s", retMsg)
return
}
retCode = 0
retMsg = fmt.Sprintf("verify app store transaction [%s] success", transactionID)
- logging.LogInfof(retMsg)
+ logging.LogInfof("%s", retMsg)
return
}
diff --git a/kernel/sql/queue.go b/kernel/sql/queue.go
index d8f1c3d261..7b4d9ea29f 100644
--- a/kernel/sql/queue.go
+++ b/kernel/sql/queue.go
@@ -303,7 +303,7 @@ func execOp(op *dbQueueOperation, tx *sql.Tx, context map[string]any) (err error
err = indexNode(tx, op.id, op.box)
default:
msg := fmt.Sprintf("unknown operation [%s]", op.action)
- logging.LogErrorf(msg)
+ logging.LogErrorf("%s", msg)
err = errors.New(msg)
}
return
diff --git a/kernel/sql/queue_asset_content.go b/kernel/sql/queue_asset_content.go
index a3f5e1e270..7a8c290b71 100644
--- a/kernel/sql/queue_asset_content.go
+++ b/kernel/sql/queue_asset_content.go
@@ -115,7 +115,7 @@ func execAssetContentOp(op *assetContentDBQueueOperation, tx *sql.Tx, context ma
err = deleteAssetContentsByPath(tx, op.path)
default:
msg := fmt.Sprintf("unknown asset content operation [%s]", op.action)
- logging.LogErrorf(msg)
+ logging.LogErrorf("%s", msg)
err = errors.New(msg)
}
return
diff --git a/kernel/sql/queue_history.go b/kernel/sql/queue_history.go
index ddc0b6819c..7da006b477 100644
--- a/kernel/sql/queue_history.go
+++ b/kernel/sql/queue_history.go
@@ -127,7 +127,7 @@ func execHistoryOp(op *historyDBQueueOperation, tx *sql.Tx, context map[string]a
err = deleteOutdatedHistories(tx, op.before)
default:
msg := fmt.Sprintf("unknown history operation [%s]", op.action)
- logging.LogErrorf(msg)
+ logging.LogErrorf("%s", msg)
err = errors.New(msg)
}
return
diff --git a/kernel/util/time.go b/kernel/util/time.go
index e196bae553..08a9766a6d 100644
--- a/kernel/util/time.go
+++ b/kernel/util/time.go
@@ -224,23 +224,23 @@ func HumanizeTime(then time.Time, lang string) string {
func humanizeTimeMagnitudes(lang string) (labels map[string]any, magnitudes []humanize.RelTimeMagnitude) {
labels = TimeLangs[lang]
magnitudes = []humanize.RelTimeMagnitude{
- {time.Second, labels["now"].(string), time.Second},
- {2 * time.Second, labels["1s"].(string), 1},
- {time.Minute, labels["xs"].(string), time.Second},
- {2 * time.Minute, labels["1m"].(string), 1},
- {time.Hour, labels["xm"].(string), time.Minute},
- {2 * time.Hour, labels["1h"].(string), 1},
- {humanize.Day, labels["xh"].(string), time.Hour},
- {2 * humanize.Day, labels["1d"].(string), 1},
- {humanize.Week, labels["xd"].(string), humanize.Day},
- {2 * humanize.Week, labels["1w"].(string), 1},
- {humanize.Month, labels["xw"].(string), humanize.Week},
- {2 * humanize.Month, labels["1M"].(string), 1},
- {humanize.Year, labels["xM"].(string), humanize.Month},
- {23 * humanize.Month, labels["1y"].(string), 1},
- {2 * humanize.Year, labels["2y"].(string), 1},
- {humanize.LongTime, labels["xy"].(string), humanize.Year},
- {math.MaxInt64, labels["max"].(string), 1},
+ {D: time.Second, Format: labels["now"].(string), DivBy: time.Second},
+ {D: 2 * time.Second, Format: labels["1s"].(string), DivBy: 1},
+ {D: time.Minute, Format: labels["xs"].(string), DivBy: time.Second},
+ {D: 2 * time.Minute, Format: labels["1m"].(string), DivBy: 1},
+ {D: time.Hour, Format: labels["xh"].(string), DivBy: time.Minute},
+ {D: 2 * time.Hour, Format: labels["1h"].(string), DivBy: 1},
+ {D: humanize.Day, Format: labels["xh"].(string), DivBy: time.Hour},
+ {D: 2 * humanize.Day, Format: labels["1d"].(string), DivBy: 1},
+ {D: humanize.Week, Format: labels["xd"].(string), DivBy: humanize.Day},
+ {D: 2 * humanize.Week, Format: labels["1w"].(string), DivBy: 1},
+ {D: humanize.Month, Format: labels["xw"].(string), DivBy: humanize.Week},
+ {D: 2 * humanize.Month, Format: labels["1M"].(string), DivBy: 1},
+ {D: humanize.Year, Format: labels["xM"].(string), DivBy: humanize.Month},
+ {D: 23 * humanize.Month, Format: labels["1y"].(string), DivBy: 1},
+ {D: 2 * humanize.Year, Format: labels["2y"].(string), DivBy: 1},
+ {D: humanize.LongTime, Format: labels["xy"].(string), DivBy: humanize.Year},
+ {D: math.MaxInt64, Format: labels["max"].(string), DivBy: 1},
}
return
}