Add an example to the scraping package
Shows example usage for the function, and how to dispaly its
output.
Signed-off-by: Het Satasiya <satasiyahet@gmail.com>
Change-Id: Ic721e99a53ccfa8c41b84a7bbe22f893d49dd931
diff --git a/scouting/scraping/BUILD b/scouting/scraping/BUILD
index 58db2b1..d9248f8 100644
--- a/scouting/scraping/BUILD
+++ b/scouting/scraping/BUILD
@@ -1,4 +1,4 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
name = "scraping",
@@ -10,3 +10,14 @@
target_compatible_with = ["@platforms//cpu:x86_64"],
visibility = ["//visibility:public"],
)
+
+go_binary(
+ name = "scraping_demo",
+ srcs = ["scraping_demo.go"],
+ target_compatible_with = ["@platforms//cpu:x86_64"],
+ visibility = ["//visibility:public"],
+ deps = [
+ "scraping",
+ "@com_github_davecgh_go_spew//spew:go_default_library",
+ ],
+)
diff --git a/scouting/scraping/scraping_demo.go b/scouting/scraping/scraping_demo.go
new file mode 100644
index 0000000..1d727f3
--- /dev/null
+++ b/scouting/scraping/scraping_demo.go
@@ -0,0 +1,20 @@
+package main
+
+// To run the demo, ensure that you have a file named scouting_config.json at the workspace root with your TBA api key in it.
+import (
+ "log"
+
+ "github.com/davecgh/go-spew/spew"
+ "github.com/frc971/971-Robot-Code/scouting/scraping"
+)
+
+func main() {
+ // Get all the matches.
+ matches, err := scraping.AllMatches("2016", "nytr", "")
+ // Fail on error.
+ if err != nil {
+ log.Fatal("Error:", err.Error)
+ }
+ // Dump the matches.
+ spew.Dump(matches)
+}