diff --git a/.github/workflows/golangci-linter.yml b/.github/workflows/golangci-linter.yml new file mode 100644 index 00000000000..0862c6fed3e --- /dev/null +++ b/.github/workflows/golangci-linter.yml @@ -0,0 +1,23 @@ +name: golangci-lint +on: [push,pull_request] +jobs: + + build: + name: Build + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + + - name: Install golangci-lint + run: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.27.0 + + - name: Run golangci-lint + run: $(go env GOPATH)/bin/golangci-lint run --disable=errcheck --timeout=10m go/... diff --git a/go/cmd/automation_client/automation_client.go b/go/cmd/automation_client/automation_client.go index 4cea96c83d0..94553f1318d 100644 --- a/go/cmd/automation_client/automation_client.go +++ b/go/cmd/automation_client/automation_client.go @@ -92,7 +92,7 @@ func main() { Parameters: params.parameters, } fmt.Printf("Sending request:\n%v", proto.MarshalTextString(enqueueRequest)) - enqueueResponse, err := client.EnqueueClusterOperation(context.Background(), enqueueRequest, grpc.FailFast(false)) + enqueueResponse, err := client.EnqueueClusterOperation(context.Background(), enqueueRequest, grpc.FailFast(false)) //nolint if err != nil { fmt.Println("Failed to enqueue ClusterOperation. Error:", err) os.Exit(4) @@ -113,7 +113,7 @@ func waitForClusterOp(client automationservicepb.AutomationClient, id string) (* Id: id, } - resp, err := client.GetClusterOperationDetails(context.Background(), req, grpc.FailFast(false)) + resp, err := client.GetClusterOperationDetails(context.Background(), req, grpc.FailFast(false)) //nolint if err != nil { return nil, fmt.Errorf("failed to get ClusterOperation Details. Request: %v Error: %v", req, err) } diff --git a/go/cmd/mysqlctl/mysqlctl.go b/go/cmd/mysqlctl/mysqlctl.go index 8793d8420a6..362e2a41bfa 100644 --- a/go/cmd/mysqlctl/mysqlctl.go +++ b/go/cmd/mysqlctl/mysqlctl.go @@ -42,7 +42,8 @@ var ( tabletUID = flag.Uint("tablet_uid", 41983, "tablet uid") mysqlSocket = flag.String("mysql_socket", "", "path to the mysql socket") - tabletAddr string + // Reason for nolint : Being used in line 246 (tabletAddr = netutil.JoinHostPort("localhost", int32(*port)) + tabletAddr string //nolint ) func initConfigCmd(subFlags *flag.FlagSet, args []string) error { diff --git a/go/cmd/zkctl/zkctl.go b/go/cmd/zkctl/zkctl.go index 7e19fd079d2..310e88c705b 100644 --- a/go/cmd/zkctl/zkctl.go +++ b/go/cmd/zkctl/zkctl.go @@ -41,7 +41,8 @@ var ( myID = flag.Uint("zk.myid", 0, "which server do you want to be? only needed when running multiple instance on one box, otherwise myid is implied by hostname") - stdin *bufio.Reader + // Reason for nolint : Used in line 54 (stdin = bufio.NewReader(os.Stdin)) in the init function + stdin *bufio.Reader //nolint ) func init() { diff --git a/go/mysql/binlog_event_make_test.go b/go/mysql/binlog_event_make_test.go index 040a0ac77c3..03de2febeca 100644 --- a/go/mysql/binlog_event_make_test.go +++ b/go/mysql/binlog_event_make_test.go @@ -307,7 +307,15 @@ func TestRowsEvent(t *testing.T) { f := NewMySQL56BinlogFormat() s := NewFakeBinlogStream() - tableID := uint64(0x102030405060) + /* + Reason for nolint + Used in line 384 to 387 + tableID = event.TableID(f) + if tableID != 0x102030405060 { + t.Fatalf("NewRowsEvent().TableID returned %x", tableID) + } + */ + tableID := uint64(0x102030405060) //nolint tm := &TableMap{ Flags: 0x8090, diff --git a/go/mysql/query_test.go b/go/mysql/query_test.go index f0529a1bc90..8273759c38d 100644 --- a/go/mysql/query_test.go +++ b/go/mysql/query_test.go @@ -641,7 +641,7 @@ func checkQueryInternal(t *testing.T, query string, sConn, cConn *Conn, result * } } -//lint:ignore U1000 for now, because deleting this function causes more errors +//nolint func writeResult(conn *Conn, result *sqltypes.Result) error { if len(result.Fields) == 0 { return conn.writeOKPacket(result.RowsAffected, result.InsertID, conn.StatusFlags, 0) diff --git a/go/mysql/replication.go b/go/mysql/replication.go index d10925b6ddd..c46642a4dc5 100644 --- a/go/mysql/replication.go +++ b/go/mysql/replication.go @@ -54,14 +54,14 @@ func (c *Conn) WriteComBinlogDumpGTID(serverID uint32, binlogFilename string, bi 4 + // data-size len(gtidSet) // data data, pos := c.startEphemeralPacketWithHeader(length) - pos = writeByte(data, pos, ComBinlogDumpGTID) - pos = writeUint16(data, pos, flags) - pos = writeUint32(data, pos, serverID) - pos = writeUint32(data, pos, uint32(len(binlogFilename))) - pos = writeEOFString(data, pos, binlogFilename) - pos = writeUint64(data, pos, binlogPos) - pos = writeUint32(data, pos, uint32(len(gtidSet))) - pos += copy(data[pos:], gtidSet) + pos = writeByte(data, pos, ComBinlogDumpGTID) //nolint + pos = writeUint16(data, pos, flags) //nolint + pos = writeUint32(data, pos, serverID) //nolint + pos = writeUint32(data, pos, uint32(len(binlogFilename))) //nolint + pos = writeEOFString(data, pos, binlogFilename) //nolint + pos = writeUint64(data, pos, binlogPos) //nolint + pos = writeUint32(data, pos, uint32(len(gtidSet))) //nolint + pos += copy(data[pos:], gtidSet) //nolint if err := c.writeEphemeralPacket(); err != nil { return NewSQLError(CRServerGone, SSUnknownSQLState, "%v", err) } diff --git a/go/mysql/replication_constants.go b/go/mysql/replication_constants.go index da0a4740744..f6689313f94 100644 --- a/go/mysql/replication_constants.go +++ b/go/mysql/replication_constants.go @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ - +//nolint:unparam package mysql // This file contains the constant definitions for this package. @@ -208,7 +208,7 @@ const ( //eXAPrepareLogEvent = 38 // MariaDB specific values. They start at 160. - eMariaAnnotateRowsEvent = 160 + eMariaAnnotateRowsEvent = 160 //nolint // Unused //eMariaBinlogCheckpointEvent = 161 eMariaGTIDEvent = 162 diff --git a/go/test/endtoend/backup/vtctlbackup/backup_utils.go b/go/test/endtoend/backup/vtctlbackup/backup_utils.go index b8922e402c7..2754baf6e76 100644 --- a/go/test/endtoend/backup/vtctlbackup/backup_utils.go +++ b/go/test/endtoend/backup/vtctlbackup/backup_utils.go @@ -128,7 +128,7 @@ func LaunchCluster(setupType int, streamMode string, stripes int) (int, error) { // if streamMode is xbstream, add some additional args to test other xtrabackup flags if streamMode == "xbstream" { - xtrabackupArgs = append(xtrabackupArgs, "-xtrabackup_prepare_flags", fmt.Sprintf("--use-memory=100M")) + xtrabackupArgs = append(xtrabackupArgs, "-xtrabackup_prepare_flags", fmt.Sprintf("--use-memory=100M")) //nolint } commonTabletArg = append(commonTabletArg, xtrabackupArgs...) @@ -661,7 +661,7 @@ func terminateRestore(t *testing.T) { assert.Fail(t, "restore in progress file missing") } tmpProcess.Process.Signal(syscall.SIGTERM) - found = true + found = true //nolint return } } diff --git a/go/test/endtoend/vtctldweb/vtctld_web_main_test.go b/go/test/endtoend/vtctldweb/vtctld_web_main_test.go index 4e70e315824..72c2fcd031c 100644 --- a/go/test/endtoend/vtctldweb/vtctld_web_main_test.go +++ b/go/test/endtoend/vtctldweb/vtctld_web_main_test.go @@ -36,9 +36,10 @@ import ( "vitess.io/vitess/go/vt/vttest" ) +//nolint var ( localCluster *vttest.LocalCluster - hostname = "localhost" + hostname = "localhost" //nolint wd selenium.WebDriver seleniumService *selenium.Service vtctldAddr string @@ -175,7 +176,7 @@ func CreateWebDriver(port int) error { return err } - name, err := wd.CurrentWindowHandle() + name, err := wd.CurrentWindowHandle() //nolint return wd.ResizeWindow(name, 1280, 1024) } @@ -201,7 +202,7 @@ func CreateWebDriver(port int) error { if err != nil { return err } - name, err := wd.CurrentWindowHandle() + name, err := wd.CurrentWindowHandle() //nolint return wd.ResizeWindow(name, 1280, 1024) } @@ -346,7 +347,7 @@ func getDashboardKeyspaces(t *testing.T) []string { dashboardContent, err := wd.FindElement(selenium.ByTagName, "vt-dashboard") require.Nil(t, err) - ksCards, err := dashboardContent.FindElements(selenium.ByClassName, "vt-keyspace-card") + ksCards, err := dashboardContent.FindElements(selenium.ByClassName, "vt-keyspace-card") //nolint var out []string for _, ks := range ksCards { out = append(out, text(t, ks)) @@ -358,10 +359,10 @@ func getDashboardKeyspaces(t *testing.T) []string { func getDashboardShards(t *testing.T) []string { wait(t, selenium.ByTagName, "vt-dashboard") - dashboardContent, err := wd.FindElement(selenium.ByTagName, "vt-dashboard") + dashboardContent, err := wd.FindElement(selenium.ByTagName, "vt-dashboard") //nolint require.Nil(t, err) - ksCards, err := dashboardContent.FindElements(selenium.ByClassName, "vt-shard-stats") + ksCards, err := dashboardContent.FindElements(selenium.ByClassName, "vt-shard-stats") //nolint var out []string for _, ks := range ksCards { out = append(out, text(t, ks)) @@ -390,7 +391,7 @@ func getShardTablets(t *testing.T) ([]string, []string) { shardContent, err := wd.FindElement(selenium.ByTagName, "vt-shard-view") require.Nil(t, err) - tableRows, err := shardContent.FindElements(selenium.ByTagName, "tr") + tableRows, err := shardContent.FindElements(selenium.ByTagName, "tr") //nolint tableRows = tableRows[1:] var tabletTypes, tabletUIDs []string diff --git a/go/test/endtoend/vtgate/schema/schema_test.go b/go/test/endtoend/vtgate/schema/schema_test.go index 0363bdcf8af..b648aafb76b 100644 --- a/go/test/endtoend/vtgate/schema/schema_test.go +++ b/go/test/endtoend/vtgate/schema/schema_test.go @@ -115,7 +115,7 @@ func TestSchemaChange(t *testing.T) { func testWithInitialSchema(t *testing.T) { // Create 4 tables - var sqlQuery = "" + var sqlQuery = "" //nolint for i := 0; i < totalTableCount; i++ { sqlQuery = fmt.Sprintf(createTable, fmt.Sprintf("vt_select_test_%02d", i)) err := clusterInstance.VtctlclientProcess.ApplySchema(keyspaceName, sqlQuery) diff --git a/go/vt/grpcclient/client.go b/go/vt/grpcclient/client.go index 612c7b6ba1d..2c317d3d30f 100644 --- a/go/vt/grpcclient/client.go +++ b/go/vt/grpcclient/client.go @@ -62,7 +62,7 @@ func Dial(target string, failFast FailFast, opts ...grpc.DialOption) (*grpc.Clie grpc.WithDefaultCallOptions( grpc.MaxCallRecvMsgSize(*grpccommon.MaxMessageSize), grpc.MaxCallSendMsgSize(*grpccommon.MaxMessageSize), - grpc.FailFast(bool(failFast)), + grpc.FailFast(bool(failFast)), //nolint ), } diff --git a/go/vt/mysqlctl/builtinbackupengine.go b/go/vt/mysqlctl/builtinbackupengine.go index 25c8b87a768..96dfa0cead0 100644 --- a/go/vt/mysqlctl/builtinbackupengine.go +++ b/go/vt/mysqlctl/builtinbackupengine.go @@ -133,7 +133,7 @@ func (be *BuiltinBackupEngine) ExecuteBackup(ctx context.Context, params BackupP // Save initial state so we can restore. slaveStartRequired := false sourceIsMaster := false - readOnly := true + readOnly := true //nolint var replicationPosition mysql.Position semiSyncMaster, semiSyncSlave := params.Mysqld.SemiSyncEnabled() diff --git a/go/vt/mysqlctl/grpcmysqlctlclient/client.go b/go/vt/mysqlctl/grpcmysqlctlclient/client.go index 0bf8323dc04..129cb226970 100644 --- a/go/vt/mysqlctl/grpcmysqlctlclient/client.go +++ b/go/vt/mysqlctl/grpcmysqlctlclient/client.go @@ -42,7 +42,7 @@ type client struct { func factory(network, addr string) (mysqlctlclient.MysqlctlClient, error) { // create the RPC client - cc, err := grpcclient.Dial(addr, grpcclient.FailFast(false), grpc.WithInsecure(), grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { + cc, err := grpcclient.Dial(addr, grpcclient.FailFast(false), grpc.WithInsecure(), grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { //nolint:staticcheck return net.DialTimeout(network, addr, timeout) })) if err != nil { diff --git a/go/vt/mysqlctl/mycnf_test.go b/go/vt/mysqlctl/mycnf_test.go index 903cae62927..a013ad33fcb 100644 --- a/go/vt/mysqlctl/mycnf_test.go +++ b/go/vt/mysqlctl/mycnf_test.go @@ -22,7 +22,6 @@ import ( "os" "strings" "testing" - "vitess.io/vitess/go/vt/dbconfigs" "vitess.io/vitess/go/vt/servenv" ) @@ -79,6 +78,8 @@ func TestMycnf(t *testing.T) { // 3. go test // 4. \rm $VTROOT/vthook/make_mycnf // 5. Add No Prefix back + +//nolint func NoTestMycnfHook(t *testing.T) { uid := uint32(11111) cnf := NewMycnf(uid, 6802) diff --git a/go/vt/mysqlctl/mysqld.go b/go/vt/mysqlctl/mysqld.go index 578ed46b254..22a512e0d1e 100644 --- a/go/vt/mysqlctl/mysqld.go +++ b/go/vt/mysqlctl/mysqld.go @@ -343,7 +343,7 @@ func (mysqld *Mysqld) startNoWait(ctx context.Context, cnf *Mycnf, mysqldArgs .. switch hr := hook.NewHook("mysqld_start", mysqldArgs).Execute(); hr.ExitStatus { case hook.HOOK_SUCCESS: // hook exists and worked, we can keep going - name = "mysqld_start hook" + name = "mysqld_start hook" //nolint case hook.HOOK_DOES_NOT_EXIST: // hook doesn't exist, run mysqld_safe ourselves log.Infof("%v: No mysqld_start hook, running mysqld_safe directly", ts) diff --git a/go/vt/mysqlctl/replication.go b/go/vt/mysqlctl/replication.go index 14fa5b39417..44e8d857316 100644 --- a/go/vt/mysqlctl/replication.go +++ b/go/vt/mysqlctl/replication.go @@ -319,10 +319,10 @@ func (mysqld *Mysqld) ResetReplication(ctx context.Context) error { // // Array indices for the results of SHOW PROCESSLIST. const ( - colConnectionID = iota - colUsername + colConnectionID = iota //nolint + colUsername //nolint colClientAddr - colDbName + colDbName //nolint colCommand ) diff --git a/go/vt/mysqlctl/tmutils/schema_test.go b/go/vt/mysqlctl/tmutils/schema_test.go index 0b851721614..812b28291b3 100644 --- a/go/vt/mysqlctl/tmutils/schema_test.go +++ b/go/vt/mysqlctl/tmutils/schema_test.go @@ -240,7 +240,7 @@ func TestSchemaDiff(t *testing.T) { }) testDiff(t, sd4, sd5, "sd4", "sd5", []string{ - fmt.Sprintf("schemas differ on table type for table table2:\nsd4: VIEW\n differs from:\nsd5: BASE TABLE"), + fmt.Sprintf("schemas differ on table type for table table2:\nsd4: VIEW\n differs from:\nsd5: BASE TABLE"), //nolint }) sd1.DatabaseSchema = "CREATE DATABASE {{.DatabaseName}}" diff --git a/go/vt/sqlparser/precedence_test.go b/go/vt/sqlparser/precedence_test.go index 8292ccddff9..c0676dee9be 100644 --- a/go/vt/sqlparser/precedence_test.go +++ b/go/vt/sqlparser/precedence_test.go @@ -158,7 +158,7 @@ func TestRandom(t *testing.T) { // The purpose of this test is to find discrepancies between Format and parsing. If for example our precedence rules are not consistent between the two, this test should find it. // The idea is to generate random queries, and pass them through the parser and then the unparser, and one more time. The result of the first unparse should be the same as the second result. seed := time.Now().UnixNano() - fmt.Println(fmt.Sprintf("seed is %d", seed)) + fmt.Println(fmt.Sprintf("seed is %d", seed)) //nolint g := newGenerator(seed, 5) endBy := time.Now().Add(1 * time.Second) diff --git a/go/vt/throttler/max_replication_lag_module.go b/go/vt/throttler/max_replication_lag_module.go index 857e8ba52ed..68b7be2bce3 100644 --- a/go/vt/throttler/max_replication_lag_module.go +++ b/go/vt/throttler/max_replication_lag_module.go @@ -594,7 +594,7 @@ func (m *MaxReplicationLagModule) decreaseAndGuessRate(r *result, now time.Time, if replicationLagChange == equal { // The replication lag did not change. Keep going at the current rate. - r.Reason = fmt.Sprintf("did not decrease the rate because the lag did not change (assuming a 1s error margin)") + r.Reason = fmt.Sprintf("did not decrease the rate because the lag did not change (assuming a 1s error margin)") //nolint return } diff --git a/go/vt/topo/consultopo/server.go b/go/vt/topo/consultopo/server.go index d141116cbf6..95f371196d5 100644 --- a/go/vt/topo/consultopo/server.go +++ b/go/vt/topo/consultopo/server.go @@ -72,7 +72,7 @@ func getClientCreds() (creds map[string]*ClientAuthCred, err error) { } if err := json.Unmarshal(data, &creds); err != nil { - err = vterrors.Wrapf(err, fmt.Sprintf("Error parsing consul_auth_static_file")) + err = vterrors.Wrapf(err, fmt.Sprintf("Error parsing consul_auth_static_file")) //nolint return creds, err } return creds, nil diff --git a/go/vt/topo/k8stopo/client/clientset/versioned/fake/register.go b/go/vt/topo/k8stopo/client/clientset/versioned/fake/register.go index 55ae45f14c3..08ff48b7608 100644 --- a/go/vt/topo/k8stopo/client/clientset/versioned/fake/register.go +++ b/go/vt/topo/k8stopo/client/clientset/versioned/fake/register.go @@ -29,7 +29,7 @@ import ( var scheme = runtime.NewScheme() var codecs = serializer.NewCodecFactory(scheme) -var parameterCodec = runtime.NewParameterCodec(scheme) +var parameterCodec = runtime.NewParameterCodec(scheme) //nolint var localSchemeBuilder = runtime.SchemeBuilder{ topov1beta1.AddToScheme, } diff --git a/go/vt/topo/k8stopo/server.go b/go/vt/topo/k8stopo/server.go index 50b81465c71..b51e9fc144f 100644 --- a/go/vt/topo/k8stopo/server.go +++ b/go/vt/topo/k8stopo/server.go @@ -150,7 +150,7 @@ func NewServer(_, root string) (*Server, error) { var config *rest.Config var err error - namespace := "default" + namespace := "default" //nolint if *kubeconfigPath == "" { log.Info("Creating new in-cluster Kubernetes config") diff --git a/go/vt/vtctl/backup.go b/go/vt/vtctl/backup.go index 89b6b1ed434..24703e37e46 100644 --- a/go/vt/vtctl/backup.go +++ b/go/vt/vtctl/backup.go @@ -134,7 +134,7 @@ func commandBackupShard(ctx context.Context, wr *wrangler.Wrangler, subFlags *fl switch tablets[i].Type { case topodatapb.TabletType_MASTER: tabletForBackup = tablets[i].Tablet - secondsBehind = 0 + secondsBehind = 0 //nolint break ChooseMaster default: continue diff --git a/go/vt/vtgate/executor.go b/go/vt/vtgate/executor.go index 58bb05ee3ff..bd037086539 100644 --- a/go/vt/vtgate/executor.go +++ b/go/vt/vtgate/executor.go @@ -1604,7 +1604,7 @@ func (e *Executor) handlePrepare(ctx context.Context, safeSession *SafeSession, var errCount uint64 if err != nil { logStats.Error = err - errCount = 1 + errCount = 1 //nolint return nil, err } logStats.RowsAffected = qr.RowsAffected diff --git a/go/vt/vtgate/executor_vschema_ddl_test.go b/go/vt/vtgate/executor_vschema_ddl_test.go index d7f320842d1..37f8b9cf6cb 100644 --- a/go/vt/vtgate/executor_vschema_ddl_test.go +++ b/go/vt/vtgate/executor_vschema_ddl_test.go @@ -92,6 +92,7 @@ func waitForVschemaTables(t *testing.T, ks string, tables []string, executor *Ex return nil } +//nolint func waitForColVindexes(t *testing.T, ks, table string, names []string, executor *Executor) *vschemapb.SrvVSchema { t.Helper() @@ -383,7 +384,7 @@ func TestExecutorAddDropVindexDDL(t *testing.T) { defer func() { *vschemaacl.AuthorizedDDLUsers = "" }() - executor, sbc1, sbc2, sbclookup := createExecutorEnv() + executor, sbc1, sbc2, sbclookup := createExecutorEnv() //nolint ks := "TestExecutor" session := NewSafeSession(&vtgatepb.Session{TargetString: ks}) vschemaUpdates := make(chan *vschemapb.SrvVSchema, 4) diff --git a/go/vt/vtgate/planbuilder/plan_test.go b/go/vt/vtgate/planbuilder/plan_test.go index 38582e14cce..30771dd9c03 100644 --- a/go/vt/vtgate/planbuilder/plan_test.go +++ b/go/vt/vtgate/planbuilder/plan_test.go @@ -345,7 +345,7 @@ func testFile(t *testing.T, filename, tempDir string, vschema *vschemaWrapper) { if fail && tempDir != "" { gotFile := fmt.Sprintf("%s/%s", tempDir, filename) ioutil.WriteFile(gotFile, []byte(strings.TrimSpace(expected.String())+"\n"), 0644) - fmt.Println(fmt.Sprintf("Errors found in plantests. If the output is correct, run `cp %s/* testdata/` to update test expectations", tempDir)) + fmt.Println(fmt.Sprintf("Errors found in plantests. If the output is correct, run `cp %s/* testdata/` to update test expectations", tempDir)) //nolint } }) } diff --git a/go/vt/workflow/resharding/workflow.go b/go/vt/workflow/resharding/workflow.go index c1c94a683dd..bfd99214d45 100644 --- a/go/vt/workflow/resharding/workflow.go +++ b/go/vt/workflow/resharding/workflow.go @@ -416,7 +416,7 @@ func (hw *horizontalReshardingWorkflow) Run(ctx context.Context, manager *workfl if err := hw.runWorkflow(); err != nil { return err } - hw.setUIMessage(fmt.Sprintf("Horizontal Resharding is finished successfully.")) + hw.setUIMessage(fmt.Sprintf("Horizontal Resharding is finished successfully.")) //nolint return nil } diff --git a/go/vt/workflow/reshardingworkflowgen/workflow.go b/go/vt/workflow/reshardingworkflowgen/workflow.go index 8485551526f..bcde4c98a8b 100644 --- a/go/vt/workflow/reshardingworkflowgen/workflow.go +++ b/go/vt/workflow/reshardingworkflowgen/workflow.go @@ -298,10 +298,10 @@ func (hw *reshardingWorkflowGen) Run(ctx context.Context, manager *workflow.Mana hw.rootUINode.BroadcastChanges(true /* updateChildren */) if err := hw.runWorkflow(); err != nil { - hw.setUIMessage(hw.rootUINode, fmt.Sprintf("Keyspace resharding failed to create workflows")) + hw.setUIMessage(hw.rootUINode, fmt.Sprintf("Keyspace resharding failed to create workflows")) //nolint return err } - hw.setUIMessage(hw.rootUINode, fmt.Sprintf("Keyspace resharding is finished successfully.")) + hw.setUIMessage(hw.rootUINode, fmt.Sprintf("Keyspace resharding is finished successfully.")) //nolint return nil } diff --git a/go/vt/wrangler/reparent.go b/go/vt/wrangler/reparent.go index 12135de9dc8..e5843a5f904 100644 --- a/go/vt/wrangler/reparent.go +++ b/go/vt/wrangler/reparent.go @@ -46,7 +46,7 @@ const ( initShardMasterOperation = "InitShardMaster" plannedReparentShardOperation = "PlannedReparentShard" emergencyReparentShardOperation = "EmergencyReparentShard" - tabletExternallyReparentedOperation = "TabletExternallyReparented" + tabletExternallyReparentedOperation = "TabletExternallyReparented" //nolint ) // ShardReplicationStatuses returns the ReplicationStatus for each tablet in a shard. diff --git a/misc/git/hooks/golangci-lint b/misc/git/hooks/golangci-lint index b21d016da5e..416cc3969bb 100755 --- a/misc/git/hooks/golangci-lint +++ b/misc/git/hooks/golangci-lint @@ -1,12 +1,12 @@ #!/bin/bash # Copyright 2019 The Vitess Authors. -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,13 +17,17 @@ # We will enable it for everything here, but with most of the linters disabled. # See: https://github.com/vitessio/vitess/issues/5503 -# NOTE(sougou): tool is disabled till it's fixed -exit +gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '^go/.*\.go$' | grep -v '^go/vt/proto/' | grep -v 'go/vt/sqlparser/sql.go') GOLANGCI_LINT=$(command -v golangci-lint >/dev/null 2>&1) if [ $? -eq 1 ]; then echo "Downloading golangci-lint..." - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.21.0 + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0 fi -golangci-lint run --disable=ineffassign,unused,gosimple,staticcheck,errcheck,structcheck,varcheck,deadcode +#golangci-lint run --disable=ineffassign,unused,gosimple,staticcheck,errcheck,structcheck,varcheck,deadcode +for gofile in $gofiles +do + golangci-lint run --disable=errcheck --timeout=10m $gofile + echo $gofile +done diff --git a/misc/git/ps1 b/misc/git/ps1 old mode 100644 new mode 100755