Skip to content

Commit

Permalink
Merge branch 'master' into patrick/nolint
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickmscott authored May 17, 2023
2 parents 2de421e + 5933b6e commit ceb3aa2
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 21 deletions.
4 changes: 4 additions & 0 deletions go/nogo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,13 @@ Relationship with other linters
~~~~~~~~~~~~~~~~~~~~~

In Golang, a linter is composed of multiple parts:

- A collection of rules (checks) that define different validations against the source code

- Optionally, each rules could be coupled with a fixer that can automatically fix the code.

- A configuration framework that allows users to enable/disable rules, and configure the rules.

- A runner binary that orchestrate the above components.

To help with the above, Go provides a framework called `analysis`_ that allows
Expand Down
1 change: 0 additions & 1 deletion go/private/actions/compilepkg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def emit_compilepkg(
outputs.append(out_cgo_export_h)
if testfilter:
args.add("-testfilter", testfilter)
args.add_all(go.sdk.experiments, before_each = "-experiment")

gc_flags = list(gc_goopts)
gc_flags.extend(go.mode.gc_goopts)
Expand Down
1 change: 0 additions & 1 deletion go/private/actions/link.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ def emit_link(
builder_args.add("-p", archive.data.importmap)
tool_args.add_all(gc_linkopts)
tool_args.add_all(go.toolchain.flags.link)
builder_args.add_all(go.sdk.experiments, before_each = "-experiment")

# Do not remove, somehow this is needed when building for darwin/arm only.
tool_args.add("-buildid=redacted")
Expand Down
1 change: 0 additions & 1 deletion go/private/actions/stdlib.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ def _build_stdlib(go):
args.add("-out", pkg.dirname)
if go.mode.race:
args.add("-race")
args.add_all(go.sdk.experiments, before_each = "-experiment")
args.add("-package", "std")
if not go.mode.pure:
args.add("-package", "runtime/cgo")
Expand Down
1 change: 1 addition & 0 deletions go/private/context.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ def go_context(ctx, attr = None):
env = {
"GOARCH": mode.goarch,
"GOOS": mode.goos,
"GOEXPERIMENT": ",".join(toolchain.sdk.experiments),
"GOROOT": goroot,
"GOROOT_FINAL": "GOROOT",
"CGO_ENABLED": "0" if mode.pure else "1",
Expand Down
6 changes: 0 additions & 6 deletions go/tools/builders/compilepkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func compilePkg(args []string) error {
var testFilter string
var gcFlags, asmFlags, cppFlags, cFlags, cxxFlags, objcFlags, objcxxFlags, ldFlags quoteMultiFlag
var coverFormat string
var experiments multiFlag
fs.Var(&unfilteredSrcs, "src", ".go, .c, .cc, .m, .mm, .s, or .S file to be filtered and compiled")
fs.Var(&coverSrcs, "cover", ".go file that should be instrumented for coverage (must also be a -src)")
fs.Var(&embedSrcs, "embedsrc", "file that may be compiled into the package with a //go:embed directive")
Expand All @@ -72,7 +71,6 @@ func compilePkg(args []string) error {
fs.Var(&cxxFlags, "cxxflags", "C++ compiler flags")
fs.Var(&objcFlags, "objcflags", "Objective-C compiler flags")
fs.Var(&objcxxFlags, "objcxxflags", "Objective-C++ compiler flags")
fs.Var(&experiments, "experiment", "Go experiments to enable via GOEXPERIMENT")
fs.Var(&ldFlags, "ldflags", "C linker flags")
fs.StringVar(&nogoPath, "nogo", "", "The nogo binary. If unset, nogo will not be run.")
fs.StringVar(&packageListPath, "package_list", "", "The file containing the list of standard library packages")
Expand Down Expand Up @@ -133,10 +131,6 @@ func compilePkg(args []string) error {
return fmt.Errorf("invalid test filter %q", testFilter)
}

if len(experiments) > 0 {
os.Setenv("GOEXPERIMENT", strings.Join(experiments, ","))
}

return compileArchive(
goenv,
importPath,
Expand Down
6 changes: 0 additions & 6 deletions go/tools/builders/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func link(args []string) error {
builderArgs, toolArgs := splitArgs(args)
stamps := multiFlag{}
xdefs := multiFlag{}
experiments := multiFlag{}
archives := archiveMultiFlag{}
flags := flag.NewFlagSet("link", flag.ExitOnError)
goenv := envFlags(flags)
Expand All @@ -51,7 +50,6 @@ func link(args []string) error {
buildmode := flags.String("buildmode", "", "Build mode used.")
flags.Var(&xdefs, "X", "A string variable to replace in the linked binary (repeated).")
flags.Var(&stamps, "stamp", "The name of a file with stamping values.")
flags.Var(&experiments, "experiment", "Go experiments to enable via GOEXPERIMENT")
conflictErrMsg := flags.String("conflict_err", "", "Error message about conflicts to report if there's a link error.")
if err := flags.Parse(builderArgs); err != nil {
return err
Expand Down Expand Up @@ -148,10 +146,6 @@ func link(args []string) error {
}
goargs = append(goargs, "-o", *outFile)

if len(experiments) > 0 {
os.Setenv("GOEXPERIMENT", strings.Join(experiments, ","))
}

// add in the unprocess pass through options
goargs = append(goargs, toolArgs...)
goargs = append(goargs, *main)
Expand Down
6 changes: 0 additions & 6 deletions go/tools/builders/stdlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ func stdlib(args []string) error {
dynlink := flags.Bool("dynlink", false, "Build in dynlink mode")
var packages multiFlag
flags.Var(&packages, "package", "Packages to build")
var experiments multiFlag
flags.Var(&experiments, "experiment", "Go experiments to enable via GOEXPERIMENT")
var gcflags quoteMultiFlag
flags.Var(&gcflags, "gcflags", "Go compiler flags")
if err := flags.Parse(args); err != nil {
Expand Down Expand Up @@ -116,10 +114,6 @@ You may need to use the flags --cpu=x64_windows --compiler=mingw-gcc.`)
os.Setenv("CGO_LDFLAGS_ALLOW", b.String())
os.Setenv("GODEBUG", "installgoroot=all")

if len(experiments) > 0 {
os.Setenv("GOEXPERIMENT", strings.Join(experiments, ","))
}

// Build the commands needed to build the std library in the right mode
// NOTE: the go command stamps compiled .a files with build ids, which are
// cryptographic sums derived from the inputs. This prevents us from
Expand Down
2 changes: 2 additions & 0 deletions tests/core/boringcrypto/boringcrypto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ go_library(
importpath = "example.com/library"
)
-- main.go --
//go:build goexperiment.boringcrypto
package main
import "example.com/library"
Expand Down

0 comments on commit ceb3aa2

Please sign in to comment.