Skip to content

Commit

Permalink
dev: add go command to dev
Browse files Browse the repository at this point in the history
Just allows you to run `go` without actually having it installed. Maybe
no one will use this but me, I don't know :)

Release Note: None
  • Loading branch information
rickystewart committed Nov 24, 2021
1 parent 13c4d31 commit 8fcd494
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/cmd/dev/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ go_library(
"dev.go",
"doctor.go",
"generate.go",
"go.go",
"lint.go",
"logic.go",
"main.go",
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/dev/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Dev is the general-purpose dev tool for working on cockroachdb/cockroach. With d
makeBuilderCmd(ret.builder),
makeDoctorCmd(ret.doctor),
makeGenerateCmd(ret.generate),
makeGoCmd(ret.gocmd),
makeTestLogicCmd(ret.testlogic),
makeLintCmd(ret.lint),
makeTestCmd(ret.test),
Expand Down
31 changes: 31 additions & 0 deletions pkg/cmd/dev/go.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2020 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package main

import "github.com/spf13/cobra"

func makeGoCmd(runE func(cmd *cobra.Command, args []string) error) *cobra.Command {
return &cobra.Command{
Use: "go <arguments>",
Short: "Run `go` with the given arguments",
Long: "Run `go` with the given arguments",
Example: "dev go mod tidy",
Args: cobra.MinimumNArgs(0),
RunE: runE,
}
}

func (d *dev) gocmd(cmd *cobra.Command, commandLine []string) error {
ctx := cmd.Context()
args := []string{"run", "@go_sdk//:bin/go", "--ui_event_filters=-DEBUG,-info,-stdout,-stderr", "--noshow_progress", "--"}
args = append(args, commandLine...)
return d.exec.CommandContextInheritingStdStreams(ctx, "bazel", args...)
}

0 comments on commit 8fcd494

Please sign in to comment.