From 0564d5a6b0f8af5fe567422960150fe1e6c7fc87 Mon Sep 17 00:00:00 2001 From: Lindsey Moore Date: Wed, 23 Jul 2025 15:40:46 -0400 Subject: [PATCH] DOCSP-51824 Standardize Run a Command usage ex --- .../usage-examples/command.txt | 1 - .../usage-examples/code-snippets/command.go | 2 - source/run-command.txt | 40 +++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/source/archive-reference-files/usage-examples/command.txt b/source/archive-reference-files/usage-examples/command.txt index 82bcecce..c8242586 100644 --- a/source/archive-reference-files/usage-examples/command.txt +++ b/source/archive-reference-files/usage-examples/command.txt @@ -1,4 +1,3 @@ -.. _golang-run-command-usage-example: ===================== Run a Command Example diff --git a/source/includes/usage-examples/code-snippets/command.go b/source/includes/usage-examples/code-snippets/command.go index 85803a86..f2b34944 100644 --- a/source/includes/usage-examples/code-snippets/command.go +++ b/source/includes/usage-examples/code-snippets/command.go @@ -35,7 +35,6 @@ func main() { }() { - // begin runCommand db := client.Database("sample_restaurants") // Retrieves statistics about the specified database @@ -49,7 +48,6 @@ func main() { if err != nil { panic(err) } - // end runCommand /* When you run this file, it should print something similar to the following: { diff --git a/source/run-command.txt b/source/run-command.txt index e1cafd68..33997f9b 100644 --- a/source/run-command.txt +++ b/source/run-command.txt @@ -168,6 +168,46 @@ plans. The output also contains information about the execution of the } } +.. _golang-run-command-usage-example: + +Run a Command Example: Full File +-------------------------------- + +.. note:: Example Setup + + This example connects to an instance of MongoDB by using a + connection URI. To learn more about connecting to your MongoDB + instance, see the :ref:`golang-mongoclient` guide. This example + also uses the ``sample_restaurants`` database + included in the :atlas:`Atlas sample datasets `. You + can load them into your database on the free tier of MongoDB Atlas + by following the :atlas:`Get Started with Atlas Guide + `. + +The following example retrieves statistics about the +``sample_restaurants`` database: + +.. io-code-block:: + :copyable: true + + .. input:: /includes/usage-examples/code-snippets/command.go + :language: go + :dedent: + + .. output:: + :language: none + :visible: false + + // results truncated + { + "avgObjSize": 548.4101901854896, + "collections": 2, + "dataSize": 14014074, + "db": "sample_restaurants", + "indexSize": 286720, + ..., + } + .. _addl-info-runcommand: Additional Information