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/go.mod b/go.mod
index a05f6de..fb6a573 100644
--- a/go.mod
+++ b/go.mod
@@ -12,6 +12,7 @@
require (
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
+ github.com/davecgh/go-spew v1.1.0
github.com/google/go-querystring v1.1.0 // indirect
golang.org/x/net v0.0.0-20200822124328-c89045814202 // indirect
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd // indirect
diff --git a/go.sum b/go.sum
index c832e6c..9ac49b8 100644
--- a/go.sum
+++ b/go.sum
@@ -15,6 +15,7 @@
github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
+github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
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)
+}