Skip to content

Commit

Permalink
rename main() entrypoints to main.go (#1901)
Browse files Browse the repository at this point in the history
Based on https://go.dev/doc/modules/layout#basic-command

The file with the `main()` function should be named `main.go`. 

This makes things easier to find while searching through source code.
  • Loading branch information
tyler-french authored Aug 28, 2024
1 parent 2d6805c commit 533d1ef
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 22 deletions.
4 changes: 2 additions & 2 deletions cmd/autogazelle/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
name = "autogazelle_lib",
srcs = [
"autogazelle.go",
"client_unix.go",
"main.go",
"server_unix.go",
],
importpath = "github.com/bazelbuild/bazel-gazelle/cmd/autogazelle",
Expand Down Expand Up @@ -57,8 +57,8 @@ filegroup(
"BUILD.bazel",
"README.rst",
"autogazelle.bash",
"autogazelle.go",
"client_unix.go",
"main.go",
"server_unix.go",
],
visibility = ["//visibility:public"],
Expand Down
File renamed without changes.
17 changes: 12 additions & 5 deletions cmd/fetch_repo/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ go_library(
"clean.go",
"copy_tree.go",
"errorscompat.go",
"fetch_repo.go",
"go_mod_download.go",
"main.go",
"module.go",
"path.go",
"vcs.go",
Expand All @@ -34,8 +34,8 @@ go_cross_binary(
)

go_test(
name = "fetch_repo_test",
srcs = ["fetch_repo_test.go"],
name = "main_test",
srcs = ["main_test.go"],
embed = [":fetch_repo_lib"],
deps = ["@org_golang_x_tools_go_vcs//:vcs"],
)
Expand All @@ -48,12 +48,19 @@ filegroup(
"clean.go",
"copy_tree.go",
"errorscompat.go",
"fetch_repo.go",
"fetch_repo_test.go",
"go_mod_download.go",
"main.go",
"main_test.go",
"module.go",
"path.go",
"vcs.go",
],
visibility = ["//visibility:public"],
)

go_test(
name = "fetch_repo_test",
srcs = ["main_test.go"],
embed = [":fetch_repo_lib"],
deps = ["@org_golang_x_tools_go_vcs//:vcs"],
)
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions cmd/gazelle/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ go_library(
"diff.go",
"fix.go",
"fix-update.go",
"gazelle.go",
"main.go",
"metaresolver.go",
"print.go",
"profiler.go",
Expand Down Expand Up @@ -73,9 +73,9 @@ filegroup(
"fix.go",
"fix-update.go",
"fix_test.go",
"gazelle.go",
"integration_test.go",
"langs.go",
"main.go",
"metaresolver.go",
"print.go",
"profiler.go",
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions cmd/generate_repo_config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")

go_library(
name = "generate_repo_config_lib",
srcs = ["generate_repo_config.go"],
srcs = ["main.go"],
importpath = "github.com/bazelbuild/bazel-gazelle/cmd/generate_repo_config",
visibility = ["//visibility:private"],
deps = [
Expand All @@ -19,7 +19,7 @@ go_binary(

go_test(
name = "generate_repo_config_test",
srcs = ["generate_repo_config_test.go"],
srcs = ["main_test.go"],
embed = [":generate_repo_config_lib"],
deps = ["//testtools"],
)
Expand All @@ -29,8 +29,8 @@ filegroup(
testonly = True,
srcs = [
"BUILD.bazel",
"generate_repo_config.go",
"generate_repo_config_test.go",
"main.go",
"main_test.go",
],
visibility = ["//visibility:public"],
)
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions cmd/move_labels/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")

go_library(
name = "move_labels_lib",
srcs = ["move_labels.go"],
srcs = ["main.go"],
importpath = "github.com/bazelbuild/bazel-gazelle/cmd/move_labels",
visibility = ["//visibility:private"],
deps = [
Expand All @@ -21,7 +21,7 @@ go_binary(

go_test(
name = "move_labels_test",
srcs = ["move_labels_test.go"],
srcs = ["main_test.go"],
embed = [":move_labels_lib"],
deps = ["//testtools"],
)
Expand All @@ -31,8 +31,8 @@ filegroup(
testonly = True,
srcs = [
"BUILD.bazel",
"move_labels.go",
"move_labels_test.go",
"main.go",
"main_test.go",
],
visibility = ["//visibility:public"],
)
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions internal/go_repository_tools_srcs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@ GO_REPOSITORY_TOOLS_SRCS = [
Label("//:BUILD.bazel"),
Label("//cmd:BUILD.bazel"),
Label("//cmd/autogazelle:BUILD.bazel"),
Label("//cmd/autogazelle:autogazelle.go"),
Label("//cmd/autogazelle:client_unix.go"),
Label("//cmd/autogazelle:main.go"),
Label("//cmd/autogazelle:server_unix.go"),
Label("//cmd/fetch_repo:BUILD.bazel"),
Label("//cmd/fetch_repo:clean.go"),
Label("//cmd/fetch_repo:copy_tree.go"),
Label("//cmd/fetch_repo:errorscompat.go"),
Label("//cmd/fetch_repo:fetch_repo.go"),
Label("//cmd/fetch_repo:go_mod_download.go"),
Label("//cmd/fetch_repo:main.go"),
Label("//cmd/fetch_repo:module.go"),
Label("//cmd/fetch_repo:path.go"),
Label("//cmd/fetch_repo:vcs.go"),
Label("//cmd/gazelle:BUILD.bazel"),
Label("//cmd/gazelle:diff.go"),
Label("//cmd/gazelle:fix-update.go"),
Label("//cmd/gazelle:fix.go"),
Label("//cmd/gazelle:gazelle.go"),
Label("//cmd/gazelle:langs.go"),
Label("//cmd/gazelle:main.go"),
Label("//cmd/gazelle:metaresolver.go"),
Label("//cmd/gazelle:print.go"),
Label("//cmd/gazelle:profiler.go"),
Label("//cmd/gazelle:update-repos.go"),
Label("//cmd/generate_repo_config:BUILD.bazel"),
Label("//cmd/generate_repo_config:generate_repo_config.go"),
Label("//cmd/generate_repo_config:main.go"),
Label("//cmd/move_labels:BUILD.bazel"),
Label("//cmd/move_labels:move_labels.go"),
Label("//cmd/move_labels:main.go"),
Label("//config:BUILD.bazel"),
Label("//config:config.go"),
Label("//config:constants.go"),
Expand Down

0 comments on commit 533d1ef

Please sign in to comment.