Move scouting/db.go into its own directory
Our Go tooling (i.e. gazelle) gets confused when the directory name
doesn't match the `package` name. I couldn't get it to resolve the
dependency on the `db` package.
This patch fixes that by moving the code (plus test) into its own
directory.
Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: I7f57912966d0a8f677782318b1d6ea2042b8b0cb
diff --git a/scouting/BUILD b/scouting/BUILD
index 8a3b3f0..836e5c3 100644
--- a/scouting/BUILD
+++ b/scouting/BUILD
@@ -1,4 +1,4 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
+load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_binary(
name = "sql_demo",
@@ -15,19 +15,3 @@
visibility = ["//visibility:private"],
deps = ["@com_github_mattn_go_sqlite3//:go-sqlite3"],
)
-
-go_library(
- name = "database",
- srcs = ["db.go"],
- importpath = "github.com/frc971/971-Robot-Code/scouting",
- target_compatible_with = ["@platforms//cpu:x86_64"],
- visibility = ["//visibility:private"],
- deps = ["@com_github_mattn_go_sqlite3//:go_default_library"],
-)
-
-go_test(
- name = "db_test",
- srcs = ["db_test.go"],
- embed = [":database"],
- target_compatible_with = ["@platforms//cpu:x86_64"],
-)
diff --git a/scouting/db/BUILD b/scouting/db/BUILD
new file mode 100644
index 0000000..e89332d
--- /dev/null
+++ b/scouting/db/BUILD
@@ -0,0 +1,17 @@
+load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+
+go_library(
+ name = "db",
+ srcs = ["db.go"],
+ importpath = "github.com/frc971/971-Robot-Code/scouting/db",
+ target_compatible_with = ["@platforms//cpu:x86_64"],
+ visibility = ["//visibility:public"],
+ deps = ["@com_github_mattn_go_sqlite3//:go-sqlite3"],
+)
+
+go_test(
+ name = "db_test",
+ srcs = ["db_test.go"],
+ embed = [":db"],
+ target_compatible_with = ["@platforms//cpu:x86_64"],
+)
diff --git a/scouting/db.go b/scouting/db/db.go
similarity index 100%
rename from scouting/db.go
rename to scouting/db/db.go
diff --git a/scouting/db_test.go b/scouting/db/db_test.go
similarity index 100%
rename from scouting/db_test.go
rename to scouting/db/db_test.go