Skip to content

Commit

Permalink
go: Bump to go 1.24. Fix some vet errors related to non-constant fo…
Browse files Browse the repository at this point in the history
…rmat strings.
  • Loading branch information
reltuk committed Feb 26, 2025
1 parent 84d916e commit 17ef5fb
Show file tree
Hide file tree
Showing 48 changed files with 76 additions and 77 deletions.
2 changes: 1 addition & 1 deletion go/cmd/dolt/commands/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ func printTableSummary(tables []string, counts map[string]*tablePatchInfo) {
header += "===== ===== ======== =======\n"
header = color.YellowString(header)

cli.Printf(header)
cli.Print(header)

totalChgCount := 0

Expand Down
6 changes: 3 additions & 3 deletions go/cmd/dolt/commands/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func addBackup(dEnv *env.DoltEnv, apr *argparser.ArgParseResults) errhand.Verbos
case env.ErrInvalidBackupURL:
return errhand.BuildDError("error: '%s' is not valid.", r.Url).AddCause(err).Build()
case env.ErrInvalidBackupName:
return errhand.BuildDError("error: invalid backup name: " + r.Name).Build()
return errhand.BuildDError("error: invalid backup name: %s", r.Name).Build()
default:
return errhand.BuildDError("error: Unable to save changes.").AddCause(err).Build()
}
Expand Down Expand Up @@ -297,7 +297,7 @@ func backup(ctx context.Context, dEnv *env.DoltEnv, b env.Remote) errhand.Verbos
case env.ErrInvalidBackupURL:
return errhand.BuildDError("error: '%s' is not valid.", b.Url).AddCause(err).Build()
case env.ErrInvalidBackupName:
return errhand.BuildDError("error: invalid backup name: " + b.Name).Build()
return errhand.BuildDError("error: invalid backup name: %s", b.Name).Build()
default:
return errhand.BuildDError("error: Unable to save changes.").AddCause(err).Build()
}
Expand Down Expand Up @@ -353,7 +353,7 @@ func restoreBackup(ctx context.Context, dEnv *env.DoltEnv, apr *argparser.ArgPar

if existingDEnv != nil {
if !force {
return errhand.BuildDError("error: cannot restore backup into " + restoredDB + ". A database with that name already exists. Did you mean to supply --force?").Build()
return errhand.BuildDError("error: cannot restore backup into %s. A database with that name already exists. Did you mean to supply --force?", restoredDB).Build()
}

tmpDir, err := existingDEnv.TempTableFilesDir()
Expand Down
4 changes: 2 additions & 2 deletions go/cmd/dolt/commands/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ func callStoredProcedure(sqlCtx *sql.Context, queryEngine cli.Queryist, args []s
if err != nil {
if strings.Contains(err.Error(), "is not fully merged") {
newErrorMessage := fmt.Sprintf("%s. If you are sure you want to delete it, run 'dolt branch -D%s'", err.Error(), generateForceDeleteMessage(args))
return HandleVErrAndExitCode(errhand.BuildDError(newErrorMessage).Build(), nil)
return HandleVErrAndExitCode(errhand.BuildDError("%s", newErrorMessage).Build(), nil)
}
return HandleVErrAndExitCode(errhand.VerboseErrorFromError(fmt.Errorf("error: %s", err.Error())), nil)
}
Expand All @@ -507,5 +507,5 @@ func callStoredProcedure(sqlCtx *sql.Context, queryEngine cli.Queryist, args []s

// BuildVerrAndExit is a shortcut for building a verbose error and calling HandleVerrAndExitCode with it
func BuildVerrAndExit(errMsg string, cause error) int {
return HandleVErrAndExitCode(errhand.BuildDError(errMsg).AddCause(cause).Build(), nil)
return HandleVErrAndExitCode(errhand.BuildDError("%s", errMsg).AddCause(cause).Build(), nil)
}
2 changes: 1 addition & 1 deletion go/cmd/dolt/commands/checkout.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func handleErrors(branchName string, err error) errhand.VerboseError {
"1) commit or reset your changes on this branch, using `dolt commit` or `dolt reset`, before checking out the other branch, " +
"2) use the `-f` flag with `dolt checkout` to force an overwrite, or " +
"3) connect to branch '%s' with the SQL server and revert or commit changes there before proceeding."
return errhand.BuildDError(str).AddCause(err).Build()
return errhand.BuildDError("%s", str).AddCause(err).Build()
} else {
bdr := errhand.BuildDError("fatal: Unexpected error checking out branch '%s'", branchName)
bdr.AddCause(err)
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/dolt/commands/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func parseArgs(apr *argparser.ArgParseResults) (string, string, errhand.VerboseE
_, err := earl.Parse(urlStr)

if err != nil {
return "", "", errhand.BuildDError("error: invalid remote url: " + urlStr).Build()
return "", "", errhand.BuildDError("error: invalid remote url: %s", urlStr).Build()
}

var dir string
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/dolt/commands/diff_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (t tabularDiffWriter) WriteTableDiffStats(diffStats []diffStatistics, oldCo

if i != 0 && i%10000 == 0 {
msg := fmt.Sprintf("prev size: %d, new size: %d, adds: %d, deletes: %d, modifications: %d\n", acc.OldRowSize, acc.NewRowSize, acc.Adds, acc.Removes, acc.Changes)
eP.Printf(msg)
eP.Printf("%s", msg)
eP.Display()
pos += len(msg)
}
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/dolt/commands/dump_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (cmd *DumpDocsCmd) dumpDocs(wr io.Writer, cmdStr string, subCommands []cli.
docs.CommandStr = fmt.Sprintf("%s %s", cmdStr, curr.Name())
err := CreateMarkdown(wr, docs)
if err != nil {
return errhand.BuildDError(fmt.Sprintf("error: Failed to create markdown for command: %s %s.", cmdStr, curr.Name())).AddCause(err).Build()
return errhand.BuildDError("error: Failed to create markdown for command: %s %s.", cmdStr, curr.Name()).AddCause(err).Build()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/dolt/commands/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestLogSigterm(t *testing.T) {
pager.Writer.Write([]byte(fmt.Sprintf("\nDate: %s", timeStr)))

formattedDesc := "\n\n\t" + strings.Replace(cMeta.Description, "\n", "\n\t", -1) + "\n\n"
pager.Writer.Write([]byte(fmt.Sprintf(formattedDesc)))
pager.Writer.Write([]byte(formattedDesc))
}

process, err := os.FindProcess(syscall.Getpid())
Expand Down
6 changes: 3 additions & 3 deletions go/cmd/dolt/commands/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (cmd LoginCmd) Exec(ctx context.Context, commandStr string, args []string,
var err error
authHost, authPort, err = net.SplitHostPort(authEndpoint)
if err != nil {
HandleVErrAndExitCode(errhand.BuildDError(fmt.Sprintf("unable to parse auth-endpoint: '%s'", authEndpoint)).AddCause(err).Build(), usage)
HandleVErrAndExitCode(errhand.BuildDError("unable to parse auth-endpoint: '%s'", authEndpoint).AddCause(err).Build(), usage)
}
authEndpoint = fmt.Sprintf("%s:%s", authHost, authPort)
} else {
Expand All @@ -132,7 +132,7 @@ func (cmd LoginCmd) Exec(ctx context.Context, commandStr string, args []string,
insecureStr := dEnv.Config.GetStringOrDefault(config.DoltLabInsecureKey, "false")
insecure, err = strconv.ParseBool(insecureStr)
if err != nil {
HandleVErrAndExitCode(errhand.BuildDError(fmt.Sprintf("The config value of '%s' is '%s' which is not a valid true/false value", config.DoltLabInsecureKey, insecureStr)).Build(), usage)
HandleVErrAndExitCode(errhand.BuildDError("The config value of '%s' is '%s' which is not a valid true/false value", config.DoltLabInsecureKey, insecureStr).Build(), usage)
}
}

Expand Down Expand Up @@ -216,7 +216,7 @@ func loginWithCreds(ctx context.Context, dEnv *env.DoltEnv, dc creds.DoltCreds,
p := cli.NewEphemeralPrinter()
linePrinter := func() func(line string) {
return func(line string) {
p.Printf(line + "\n")
p.Printf("%s\n", line)
p.Display()
}
}()
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/dolt/commands/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func handlePushError(err error, usage cli.UsagePrinter) int {
cli.Println("hint: check that user.email in 'dolt config --list' has write perms to DoltHub repo")
}
if rpcErr, ok := err.(*remotestorage.RpcError); ok {
verr = errhand.BuildDError("error: push failed").AddCause(err).AddDetails(rpcErr.FullDetails()).Build()
verr = errhand.BuildDError("error: push failed").AddCause(err).AddDetails("%s", rpcErr.FullDetails()).Build()
} else {
verr = errhand.BuildDError("error: push failed").AddCause(err).Build()
}
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/dolt/commands/read_tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func getRemoteDBAtCommit(ctx context.Context, remoteUrl string, remoteUrlParams
}
cm, ok := optCmt.ToCommit()
if !ok {
return nil, nil, errhand.BuildDError(doltdb.ErrGhostCommitEncountered.Error()).Build()
return nil, nil, errhand.BuildDError("%s", doltdb.ErrGhostCommitEncountered.Error()).Build()
}

srcRoot, err := cm.GetRootValue(ctx)
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/dolt/commands/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func addRemoteLocaly(remoteName, remoteUrl string, params map[string]string, dEn
case env.ErrInvalidRemoteURL:
return errhand.BuildDError("error: '%s' is not valid.", rmot.Url).AddCause(err).Build()
case env.ErrInvalidRemoteName:
return errhand.BuildDError("error: invalid remote name: " + rmot.Name).Build()
return errhand.BuildDError("error: invalid remote name: %s", rmot.Name).Build()
default:
return errhand.BuildDError("error: Unable to save changes.").AddCause(err).Build()
}
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/dolt/commands/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func handleResetError(err error, usage cli.UsagePrinter) int {
}

for _, tbl := range tbls {
bdr.AddDetails("\t" + tbl.Name)
bdr.AddDetails("\t%s", tbl.Name)
}

return HandleVErrAndExitCode(bdr.Build(), usage)
Expand Down
8 changes: 4 additions & 4 deletions go/cmd/dolt/commands/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,9 @@ func formatQueryError(message string, err error) errhand.VerboseError {
)

if se, ok := vterrors.AsSyntaxError(err); ok {
verrBuilder := errhand.BuildDError(message)
verrBuilder := errhand.BuildDError("%s", message)
verrBuilder.AddDetails("Error parsing SQL: ")
verrBuilder.AddDetails(se.Message)
verrBuilder.AddDetails("%s", se.Message)

statement := se.Statement
position := se.Position
Expand Down Expand Up @@ -493,15 +493,15 @@ func formatQueryError(message string, err error) errhand.VerboseError {
}
}

verrBuilder.AddDetails(prevLines + statement)
verrBuilder.AddDetails("%s%s", prevLines, statement)

marker := make([]rune, position+1)
for i := 0; i < position; i++ {
marker[i] = ' '
}

marker[position] = '^'
verrBuilder.AddDetails(string(marker))
verrBuilder.AddDetails("%s", string(marker))

return verrBuilder.Build()
} else {
Expand Down
3 changes: 1 addition & 2 deletions go/cmd/dolt/commands/tblcmds/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,8 +807,7 @@ func newDataMoverErrToVerr(mvOpts *importOptions, err *mvdata.DataMoverCreationE

case mvdata.CreateMapperErr:
bdr := errhand.BuildDError("Error creating input to output mapper.")
details := fmt.Sprintf("When attempting to move data from %s to %s, could not create a mapper.", mvOpts.src.String(), mvOpts.destTableName)
bdr.AddDetails(details)
bdr.AddDetails("When attempting to move data from %s to %s, could not create a mapper.", mvOpts.src.String(), mvOpts.destTableName)
bdr.AddCause(err.Cause)

return bdr.AddCause(err.Cause).Build()
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/dolt/commands/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ func PrintCommitInfo(pager *outputpager.Pager, minParents int, showParents, show
if len(comm.parentHashes) > 1 {
pager.Writer.Write([]byte(fmt.Sprintf("\nMerge:")))
for _, h := range comm.parentHashes {
pager.Writer.Write([]byte(fmt.Sprintf(" " + h)))
pager.Writer.Write([]byte(" " + h))
}
}

Expand Down
6 changes: 3 additions & 3 deletions go/cmd/dolt/commands/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (cmd VersionCmd) ExecWithArgParser(ctx context.Context, apr *argparser.ArgP
verr := checkAndPrintVersionOutOfDateWarning(cmd.VersionStr, dEnv)
if verr != nil {
// print error but don't fail
cli.PrintErrf(color.YellowString(verr.Verbose()))
cli.PrintErr(color.YellowString(verr.Verbose()))
}
}

Expand Down Expand Up @@ -189,7 +189,7 @@ func checkAndPrintVersionOutOfDateWarning(curVersion string, dEnv *env.DoltEnv)
// check and print a warning message. This can happen for example, if we get a 403 from GitHub when
// querying for the latest release tag.
if latestRelease == "" {
cli.Printf(color.YellowString("Warning: unable to query latest released Dolt version"))
cli.Print(color.YellowString("Warning: unable to query latest released Dolt version"))
return nil
}

Expand All @@ -199,7 +199,7 @@ func checkAndPrintVersionOutOfDateWarning(curVersion string, dEnv *env.DoltEnv)
return verr
}
if isOutOfDate {
cli.Printf(color.YellowString("Warning: you are on an old version of Dolt. The newest version is %s.\n", latestRelease))
cli.Print(color.YellowString("Warning: you are on an old version of Dolt. The newest version is %s.\n", latestRelease))
printDisableVersionCheckWarning(dEnv, homeDir, curVersion)
}

Expand Down
4 changes: 2 additions & 2 deletions go/cmd/dolt/errhand/panic_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ func PanicToVError(errMsg string, f func() VerboseError) VerboseError {
func() {
defer func() {
if r := recover(); r != nil {
bdr := BuildDError(errMsg)
bdr := BuildDError("%s", errMsg)

if recErr, ok := r.(error); ok {
bdr.AddCause(recErr)
} else {
bdr.AddDetails(fmt.Sprint(r))
bdr.AddDetails("%s", fmt.Sprint(r))
}

err = bdr.Build()
Expand Down
2 changes: 1 addition & 1 deletion go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,4 @@ require (

replace github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi => ./gen/proto/dolt/services/eventsapi

go 1.23.3
go 1.24.0
4 changes: 2 additions & 2 deletions go/go.work
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
go 1.23.3
go 1.24.0

toolchain go1.23.3
toolchain go1.24.0

use (
.
Expand Down
2 changes: 1 addition & 1 deletion go/libraries/doltcore/rowconv/field_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func NameMapperFromFile(mappingFile string, FS filesys.ReadableFS) (NameMapper,
err := filesys.UnmarshalJSONFile(FS, mappingFile, &nm)

if err != nil {
return nil, errhand.BuildDError(ErrMappingFileRead.Error()).AddCause(err).Build()
return nil, errhand.BuildDError("%s", ErrMappingFileRead.Error()).AddCause(err).Build()
}

return nm, nil
Expand Down
4 changes: 2 additions & 2 deletions go/libraries/doltcore/schema/typeinfo/typeinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func testTypeInfoEquals(t *testing.T, tiArrays [][]TypeInfo) {
t.Run(ti1.String(), func(t *testing.T) {
for j := range tiArray {
ti2 := tiArray[j]
t.Run(fmt.Sprintf(ti2.String()), func(t *testing.T) {
t.Run(ti2.String(), func(t *testing.T) {
equality := ti1.Equals(ti2)
if i == j {
assert.True(t, equality)
Expand All @@ -184,7 +184,7 @@ func testTypeInfoEquals(t *testing.T, tiArrays [][]TypeInfo) {
continue
}
for _, otherTi := range tiArray2 {
t.Run(fmt.Sprintf(otherTi.String()), func(t *testing.T) {
t.Run(otherTi.String(), func(t *testing.T) {
equality := firstTi.Equals(otherTi)
assert.False(t, equality)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (d *DoltBinlogPrimaryController) validateReplicationConfiguration() *mysql.
}
logBin, _, err := gmstypes.Boolean.Convert(logBinValue)
if err != nil {
return mysql.NewSQLError(mysql.ERUnknownError, "HY000", err.Error())
return mysql.NewSQLError(mysql.ERUnknownError, "HY000", "%s", err.Error())
}
if logBin.(int8) != 1 {
return mysql.NewSQLError(mysql.ERMasterFatalReadingBinlog, "HY000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ func (a *binlogReplicaApplier) processBinlogEvent(ctx *sql.Context, engine *gms.
}
if flags != 0 {
msg := fmt.Sprintf("unsupported binlog protocol message: TableMap event with unsupported flags '%x'", flags)
ctx.GetLogger().Errorf(msg)
ctx.GetLogger().Error(msg)
DoltBinlogReplicaController.setSqlError(mysql.ERUnknownError, msg)
}
a.tableMapsById[tableId] = tableMap
Expand Down Expand Up @@ -664,7 +664,7 @@ func (a *binlogReplicaApplier) processRowEvent(ctx *sql.Context, event mysql.Bin
}
if flags != 0 {
msg := fmt.Sprintf("unsupported binlog protocol message: row event with unsupported flags '%x'", flags)
ctx.GetLogger().Errorf(msg)
ctx.GetLogger().Error(msg)
DoltBinlogReplicaController.setSqlError(mysql.ERUnknownError, msg)
}
schema, tableName, err := getTableSchema(ctx, engine, tableMap.Name, tableMap.Database)
Expand Down
2 changes: 1 addition & 1 deletion go/libraries/doltcore/sqle/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,7 @@ func (db Database) createDoltTable(ctx *sql.Context, tableName string, schemaNam
})

if len(conflictingTbls) > 0 {
return fmt.Errorf(strings.Join(conflictingTbls, "\n"))
return fmt.Errorf("%s", strings.Join(conflictingTbls, "\n"))
}

newRoot, err := doltdb.CreateEmptyTable(ctx, root, doltdb.TableName{Name: tableName, Schema: schemaName}, doltSch)
Expand Down
2 changes: 1 addition & 1 deletion go/libraries/doltcore/sqle/dprocedures/dolt_checkout.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ func checkoutRemoteBranch(ctx *sql.Context, dSess *dsess.DoltSession, dbName str

refSpec, err := ref.ParseRefSpecForRemote(remoteRef.GetRemote(), remoteRef.GetBranch())
if err != nil {
return "", errhand.BuildDError(fmt.Errorf("%w: '%s'", err, remoteRef.GetRemote()).Error()).Build()
return "", errhand.BuildDError("%s: '%s'", err.Error(), remoteRef.GetRemote()).Build()
}

headRef, err := dbData.Rsr.CWBHeadRef()
Expand Down
2 changes: 1 addition & 1 deletion go/libraries/doltcore/sqle/dprocedures/dolt_clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func getDirectoryAndUrlString(apr *argparser.ArgParseResults) (string, string, e
urlStr := apr.Arg(0)
_, err := earl.Parse(urlStr)
if err != nil {
return "", "", errhand.BuildDError("error: invalid remote url: " + urlStr).Build()
return "", "", errhand.BuildDError("error: invalid remote url: %s", urlStr).Build()
}

var dir string
Expand Down
12 changes: 6 additions & 6 deletions go/libraries/doltcore/sqle/dprocedures/dolt_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,20 @@ func doDoltCommit(ctx *sql.Context, args []string) (string, bool, error) {
if apr.Contains(cli.UpperCaseAllFlag) {
roots, err = actions.StageAllTables(ctx, roots, true)
if err != nil {
return "", false, fmt.Errorf(err.Error())
return "", false, err
}
roots, err = actions.StageDatabase(ctx, roots)
if err != nil {
return "", false, fmt.Errorf(err.Error())
return "", false, err
}
} else if apr.Contains(cli.AllFlag) {
roots, err = actions.StageModifiedAndDeletedTables(ctx, roots)
if err != nil {
return "", false, fmt.Errorf(err.Error())
return "", false, err
}
roots, err = actions.StageDatabase(ctx, roots)
if err != nil {
return "", false, fmt.Errorf(err.Error())
return "", false, err
}
}

Expand Down Expand Up @@ -142,7 +142,7 @@ func doDoltCommit(ctx *sql.Context, args []string) (string, bool, error) {
t, err = dconfig.ParseDate(commitTimeStr)

if err != nil {
return "", false, fmt.Errorf(err.Error())
return "", false, err
}
} else if datas.CustomAuthorDate {
t = datas.AuthorDate()
Expand All @@ -151,7 +151,7 @@ func doDoltCommit(ctx *sql.Context, args []string) (string, bool, error) {
if apr.Contains(cli.ForceFlag) {
err = ctx.SetSessionVariable(ctx, "dolt_force_transaction_commit", 1)
if err != nil {
return "", false, fmt.Errorf(err.Error())
return "", false, err
}
}

Expand Down
Loading

0 comments on commit 17ef5fb

Please sign in to comment.