diff --git a/go/cmd/vtctldclient/command/vreplication/mount/mount.go b/go/cmd/vtctldclient/command/vreplication/mount/mount.go index 95ce3961e71..33bc69e5626 100644 --- a/go/cmd/vtctldclient/command/vreplication/mount/mount.go +++ b/go/cmd/vtctldclient/command/vreplication/mount/mount.go @@ -143,9 +143,7 @@ func commandList(cmd *cobra.Command, args []string) error { if err != nil { return err } - if err != nil { - return err - } + data, err := json.Marshal(resp) if err != nil { return err diff --git a/go/mysql/json/marshal.go b/go/mysql/json/marshal.go index 8e63cddb171..d1a0072ccbb 100644 --- a/go/mysql/json/marshal.go +++ b/go/mysql/json/marshal.go @@ -169,13 +169,12 @@ func MarshalSQLValue(buf []byte) (*sqltypes.Value, error) { if len(buf) == 0 { buf = sqltypes.NullBytes } + jsonVal, err := parser.ParseBytes(buf) if err != nil { return nil, err } + newVal := sqltypes.MakeTrusted(querypb.Type_JSON, jsonVal.MarshalSQLTo(nil)) - if err != nil { - return nil, err - } return &newVal, nil } diff --git a/go/test/endtoend/cluster/cluster_process.go b/go/test/endtoend/cluster/cluster_process.go index 3a1390eec0c..a9cc482b9e3 100644 --- a/go/test/endtoend/cluster/cluster_process.go +++ b/go/test/endtoend/cluster/cluster_process.go @@ -765,19 +765,18 @@ func (cluster *LocalProcessCluster) populateVersionInfo() error { return err } +var versionRegex = regexp.MustCompile(`Version: ([0-9]+)\.([0-9]+)\.([0-9]+)`) + func GetMajorVersion(binaryName string) (int, error) { version, err := exec.Command(binaryName, "--version").Output() if err != nil { return 0, err } - versionRegex := regexp.MustCompile(`Version: ([0-9]+)\.([0-9]+)\.([0-9]+)`) v := versionRegex.FindStringSubmatch(string(version)) if len(v) != 4 { return 0, fmt.Errorf("could not parse server version from: %s", version) } - if err != nil { - return 0, fmt.Errorf("could not parse server version from: %s", version) - } + return strconv.Atoi(v[1]) } diff --git a/go/vt/binlog/binlogplayer/dbclient.go b/go/vt/binlog/binlogplayer/dbclient.go index ce2ccaccb17..e4896048db5 100644 --- a/go/vt/binlog/binlogplayer/dbclient.go +++ b/go/vt/binlog/binlogplayer/dbclient.go @@ -183,8 +183,6 @@ func (dcr *dbClientImplWithSidecarDBReplacement) ExecuteFetchMulti(query string, } qps[i] = uq } - if err != nil { - return nil, err - } + return dcr.dbClientImpl.ExecuteFetchMulti(strings.Join(qps, ";"), maxrows) } diff --git a/go/vt/mysqlctl/mycnf.go b/go/vt/mysqlctl/mycnf.go index dad91e20fed..7ae2d5d0aa9 100644 --- a/go/vt/mysqlctl/mycnf.go +++ b/go/vt/mysqlctl/mycnf.go @@ -178,9 +178,7 @@ func ReadMycnf(mycnf *Mycnf, waitTime time.Duration) (*Mycnf, error) { defer f.Close() buf := bufio.NewReader(f) - if err != nil { - return nil, err - } + mycnf.mycnfMap = make(map[string]string) var lval, rval string var parts [][]byte diff --git a/go/vt/mysqlctl/replication.go b/go/vt/mysqlctl/replication.go index 1dd03d901cb..af20bbef85f 100644 --- a/go/vt/mysqlctl/replication.go +++ b/go/vt/mysqlctl/replication.go @@ -237,7 +237,8 @@ func (mysqld *Mysqld) IsSuperReadOnly() (bool, error) { if err != nil { return false, err } - if err == nil && len(qr.Rows) == 1 { + + if len(qr.Rows) == 1 { sro := qr.Rows[0][0].ToString() if sro == "1" || sro == "ON" { return true, nil diff --git a/go/vt/schemadiff/schema.go b/go/vt/schemadiff/schema.go index ec9174dd232..61b06236bb4 100644 --- a/go/vt/schemadiff/schema.go +++ b/go/vt/schemadiff/schema.go @@ -1041,10 +1041,8 @@ func (s *Schema) getTableColumnNames(t *CreateTableEntity) (columnNames []*sqlpa } // getViewColumnNames returns the names of aliased columns returned by a given view. -func (s *Schema) getViewColumnNames(v *CreateViewEntity, schemaInformation *declarativeSchemaInformation) ( - columnNames []*sqlparser.IdentifierCI, - err error, -) { +func (s *Schema) getViewColumnNames(v *CreateViewEntity, schemaInformation *declarativeSchemaInformation) ([]*sqlparser.IdentifierCI, error) { + var columnNames []*sqlparser.IdentifierCI for _, node := range v.Select.GetColumns() { switch node := node.(type) { case *sqlparser.StarExpr: @@ -1074,8 +1072,5 @@ func (s *Schema) getViewColumnNames(v *CreateViewEntity, schemaInformation *decl } } - if err != nil { - return nil, err - } return columnNames, nil } diff --git a/go/vt/sqlparser/parse_test.go b/go/vt/sqlparser/parse_test.go index d2396cabe17..cc45db024d5 100644 --- a/go/vt/sqlparser/parse_test.go +++ b/go/vt/sqlparser/parse_test.go @@ -6346,7 +6346,7 @@ func parsePartial(r *bufio.Reader, readType []string, lineno int, fileName strin if returnTypeNumber != -1 { break } - panic(fmt.Errorf("error reading file %s: line %d: %s - Expected keyword", fileName, lineno, err.Error())) + panic(fmt.Errorf("error reading file %s: line %d: Expected keyword", fileName, lineno)) } input := "" for { diff --git a/go/vt/zkctl/zkconf.go b/go/vt/zkctl/zkconf.go index 7361408c3fc..92be0eb492e 100644 --- a/go/vt/zkctl/zkconf.go +++ b/go/vt/zkctl/zkconf.go @@ -104,18 +104,16 @@ func MakeZooCfg(cnfFiles []string, cnf *ZkConfig, header string) (string, error) for _, line := range strings.Split(header, "\n") { fmt.Fprintf(&myTemplateSource, "## %v\n", strings.TrimSpace(line)) } - var dataErr error + for _, path := range cnfFiles { - data, dataErr := os.ReadFile(path) - if dataErr != nil { + data, err := os.ReadFile(path) + if err != nil { continue } + myTemplateSource.WriteString("## " + path + "\n") myTemplateSource.Write(data) } - if dataErr != nil { - return "", dataErr - } myTemplateSource.WriteString("\n") // in case `data` did not end with a newline for _, extra := range cnf.Extra { @@ -126,9 +124,9 @@ func MakeZooCfg(cnfFiles []string, cnf *ZkConfig, header string) (string, error) if err != nil { return "", err } + var cnfData strings.Builder - err = myTemplate.Execute(&cnfData, cnf) - if err != nil { + if err := myTemplate.Execute(&cnfData, cnf); err != nil { return "", err } return cnfData.String(), nil