summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxegineering <me@xegineering.eu>2024-10-02 19:59:59 +0200
committerxegineering <me@xegineering.eu>2024-10-02 19:59:59 +0200
commit8db6c63f1bd3d4dc54dddbacf411ae6a9f33f6de (patch)
tree06fe57b65eb0cd4b3f9f2fbed4668c403c4b875d
parent516fa4b31da2f2a004e1c7f309c1e34803d18555 (diff)
downloadsoundbox-go-8db6c63f1bd3d4dc54dddbacf411ae6a9f33f6de.tar
soundbox-go-8db6c63f1bd3d4dc54dddbacf411ae6a9f33f6de.tar.zst
soundbox-go-8db6c63f1bd3d4dc54dddbacf411ae6a9f33f6de.zip
Add basic example
This gives a brief introduction how the library should be used. Furthermore it has an output string comment making sure with the test suite that it actually works.
-rw-r--r--examples_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/examples_test.go b/examples_test.go
new file mode 100644
index 0000000..1320cd6
--- /dev/null
+++ b/examples_test.go
@@ -0,0 +1,21 @@
+package soundbox_test
+
+import (
+ "fmt"
+ "log"
+
+ "xengineering.eu/soundbox"
+)
+
+// ExampleSoundbox demonstrates how to instantiate a Soundbox struct. The used
+// MAC address if from a private range according to
+// https://www.rfc-editor.org/rfc/rfc9542.html#name-48-bit-mac-documentation-va.
+func ExampleSoundbox() {
+ s, err := soundbox.NewSoundbox("00:00:5E:00:53:01")
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ fmt.Printf("Soundbox with MAC address %v", s.HardwareAddr)
+ // Output: Soundbox with MAC address 00:00:5e:00:53:01
+}