github.com/dancsecs/gotomd@v0.0.0-20240310162206-65c4805cf510/example1/README.md (about)

     1  <!--- gotomd::Auto:: See github.com/dancsecs/gotomd **DO NOT MODIFY** -->
     2  
     3  # Package example1
     4  
     5  This project is used by the Szerszam utility function to test its markdown
     6  update methods against an independent standalone project. All features
     7  will be tested against this file so it will be updated and changed often.
     8  
     9  The following will be replaced by the go package documentation
    10  
    11  <!--- gotomd::Bgn::doc::./package -->
    12  ```go
    13  package example1
    14  ```
    15  
    16  Package example1 exists in order to test various go to git
    17  markdown (gToMD) extraction utilities.  Various object will be defined that
    18  exhibit the various comment and declaration options permitted by gofmt.
    19  
    20  # Heading
    21  
    22  This paragraph will demonstrating further documentation under a "markdown"
    23  header.
    24  
    25  Declarations can be single-line or multi-line blocks or constructions.  Each
    26  type will be included here for complete testing.
    27  <!--- gotomd::End::doc::./package -->
    28  
    29  Here we will add function documentation:
    30  
    31  <!--- gotomd::Bgn::doc::./TimesTwo -->
    32  ```go
    33  func TimesTwo(i int) int
    34  ```
    35  
    36  TimesTwo returns the value times two.
    37  <!--- gotomd::End::doc::./TimesTwo -->
    38  
    39  and another:
    40  
    41  <!--- gotomd::Bgn::doc::./TimesThree -->
    42  ```go
    43  func TimesThree(i int) int
    44  ```
    45  
    46  TimesThree returns the value times three.
    47  <!--- gotomd::End::doc::./TimesThree -->
    48  
    49  and the defined interface:
    50  
    51  <!--- gotomd::Bgn::doc::./InterfaceType -->
    52  ```go
    53  type InterfaceType interface {
    54      func(int) int
    55  }
    56  ```
    57  
    58  InterfaceType tests the documentation of interfaces.
    59  <!--- gotomd::End::doc::./InterfaceType -->
    60  
    61  and the defined structure:
    62  
    63  <!--- gotomd::Bgn::doc::./StructureType -->
    64  ```go
    65  type StructureType struct {
    66      // F1 is the first test field of the structure.
    67      F1 string
    68      // F2 is the second test field of the structure.
    69      F2 int
    70  }
    71  ```
    72  
    73  StructureType tests the documentation of structures.
    74  <!--- gotomd::End::doc::./StructureType -->
    75  
    76  and run a specific test
    77  
    78  <!--- gotomd::Bgn::tst::./Test_PASS_Example1 -->
    79  ```bash
    80  go test -v -cover -run Test_PASS_Example1 .
    81  ```
    82  
    83  $\small{\texttt{===\unicode{160}RUN\unicode{160}\unicode{160}\unicode{160}Test&#x332;PASS&#x332;Example1}}$
    84  <br>
    85  $\small{\texttt{---\unicode{160}PASS:\unicode{160}Test&#x332;PASS&#x332;Example1\unicode{160}(0.0s)}}$
    86  <br>
    87  $\small{\texttt{PASS}}$
    88  <br>
    89  $\small{\texttt{coverage:\unicode{160}100.0&#xFE6A;\unicode{160}of\unicode{160}statements}}$
    90  <br>
    91  $\small{\texttt{ok\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}github.com/dancsecs/gotomd/example1\unicode{160}\unicode{160}\unicode{160}\unicode{160}coverage:\unicode{160}100.0&#xFE6A;\unicode{160}of\unicode{160}statements}}$
    92  <br>
    93  <!--- gotomd::End::tst::./Test_PASS_Example1 -->
    94  
    95  or run all tests in a package:
    96  
    97  <!--- gotomd::Bgn::tst::./package -->
    98  ```bash
    99  go test -v -cover .
   100  ```
   101  
   102  $\small{\texttt{===\unicode{160}RUN\unicode{160}\unicode{160}\unicode{160}Test&#x332;PASS&#x332;Example1}}$
   103  <br>
   104  $\small{\texttt{---\unicode{160}PASS:\unicode{160}Test&#x332;PASS&#x332;Example1\unicode{160}(0.0s)}}$
   105  <br>
   106  $\small{\texttt{===\unicode{160}RUN\unicode{160}\unicode{160}\unicode{160}Test&#x332;FAIL&#x332;Example1}}$
   107  <br>
   108  $\small{\texttt{\unicode{160}\unicode{160}\unicode{160}\unicode{160}example1&#x332;test.go:29:\unicode{160}unexpected\unicode{160}int:}}$
   109  <br>
   110  $\small{\texttt{\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\emph{2+2=5\unicode{160}(is\unicode{160}true\unicode{160}for\unicode{160}big\unicode{160}values\unicode{160}of\unicode{160}two)}:}}$
   111  <br>
   112  $\small{\texttt{\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\color{magenta}GOT:\unicode{160}\color{default}\color{darkturquoise}4\color{default}}}$
   113  <br>
   114  $\small{\texttt{\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\color{cyan}WNT:\unicode{160}\color{default}\color{darkturquoise}5\color{default}}}$
   115  <br>
   116  $\small{\texttt{\unicode{160}\unicode{160}\unicode{160}\unicode{160}example1&#x332;test.go:30:\unicode{160}unexpected\unicode{160}string:}}$
   117  <br>
   118  $\small{\texttt{\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\color{magenta}GOT:\unicode{160}\color{default}\color{green}New\unicode{160}in\unicode{160}Got\color{default}\unicode{160}Similar\unicode{160}in\unicode{160}(\color{darkturquoise}1\color{default})\unicode{160}both}}$
   119  <br>
   120  $\small{\texttt{\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\color{cyan}WNT:\unicode{160}\color{default}\unicode{160}Similar\unicode{160}in\unicode{160}(\color{darkturquoise}2\color{default})\unicode{160}both\color{red},\unicode{160}new\unicode{160}in\unicode{160}Wnt\color{default}}}$
   121  <br>
   122  $\small{\texttt{\unicode{160}\unicode{160}\unicode{160}\unicode{160}example1&#x332;test.go:36:\unicode{160}Unexpected\unicode{160}stdout\unicode{160}Entry:\unicode{160}got\unicode{160}(1\unicode{160}lines)\unicode{160}-\unicode{160}want\unicode{160}(1\unicode{160}lines)}}$
   123  <br>
   124  $\small{\texttt{\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\color{darkturquoise}0\color{default}:\color{darkturquoise}0\color{default}\unicode{160}This\unicode{160}output\unicode{160}line\unicode{160}\color{red}is\color{default}\color{yellow}/\color{default}\color{green}will\unicode{160}be\color{default}\unicode{160}different}}$
   125  <br>
   126  $\small{\texttt{\unicode{160}\unicode{160}\unicode{160}\unicode{160}example1&#x332;test.go:40:\unicode{160}unexpected\unicode{160}string:}}$
   127  <br>
   128  $\small{\texttt{\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\color{magenta}GOT:\unicode{160}\color{default}\color{darkturquoise}Total\color{default}:\unicode{160}6}}$
   129  <br>
   130  $\small{\texttt{\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\unicode{160}\color{cyan}WNT:\unicode{160}\color{default}\color{darkturquoise}Sum\color{default}:\unicode{160}6}}$
   131  <br>
   132  $\small{\texttt{---\unicode{160}FAIL:\unicode{160}Test&#x332;FAIL&#x332;Example1\unicode{160}(0.0s)}}$
   133  <br>
   134  $\small{\texttt{FAIL}}$
   135  <br>
   136  $\small{\texttt{coverage:\unicode{160}100.0&#xFE6A;\unicode{160}of\unicode{160}statements}}$
   137  <br>
   138  $\small{\texttt{FAIL\unicode{160}github.com/dancsecs/gotomd/example1\unicode{160}0.0s}}$
   139  <br>
   140  $\small{\texttt{FAIL}}$
   141  <br>
   142  <!--- gotomd::End::tst::./package -->
   143  
   144  or include a file
   145  
   146  <!--- gotomd::Bgn::file::./example1.go -->
   147  ```bash
   148  cat ./example1.go
   149  ```
   150  
   151  ```go
   152  // Package example1 exists in order to test various go to git
   153  // markdown (gToMD) extraction utilities.  Various object will be defined that
   154  // exhibit the various comment and declaration options permitted by gofmt.
   155  //
   156  // # Heading
   157  //
   158  // This paragraph will demonstrating further documentation under a "markdown"
   159  // header.
   160  //
   161  // Declarations can be single-line or multi-line blocks or constructions.  Each
   162  // type will be included here for complete testing.
   163  package example1
   164  
   165  import "strconv"
   166  
   167  // ConstDeclSingleCmtSingle has a single-line comment.
   168  const ConstDeclSingleCmtSingle = "single-line declaration and comment"
   169  
   170  // ConstDeclSingleCmtMulti has a multiline
   171  // comment.
   172  const ConstDeclSingleCmtMulti = "single-line declaration and comment"
   173  
   174  // ConstDeclMultiCmtSingle has a single-line comment with a multiline decl.
   175  const ConstDeclMultiCmtSingle = `multiline constant
   176  definition
   177  `
   178  
   179  // ConstDeclMultiCmtMulti has a multiline comment with
   180  // a multiline decl.
   181  const ConstDeclMultiCmtMulti = `multiline constant
   182  definition
   183  `
   184  
   185  // ConstDeclConstrCmtSingle has a single-line comment with a multiline decl.
   186  const ConstDeclConstrCmtSingle = `multiline constant` + "\n" +
   187      ConstDeclMultiCmtSingle + " including other constants: \n" +
   188      ConstDeclSingleCmtSingle + "\n" + `
   189  =========end of constant=============
   190  `
   191  
   192  // ConstDeclConstrCmtMulti has a multiline comment with
   193  // a multiline decl.
   194  const ConstDeclConstrCmtMulti = `multiline constant` + "\n" +
   195      ConstDeclMultiCmtSingle + " including other constants: \n" +
   196      ConstDeclSingleCmtSingle + "\n" + `
   197  =========end of constant=============
   198  `
   199  
   200  // ConstantSingleLine tests single line constant definitions.
   201  const ConstantSingleLine = "this is defined on a single-line"
   202  
   203  // ConstantMultipleLines1 test a multiline comment with string addition.
   204  // Also with longer:
   205  //
   206  // multiline comments with spacing.
   207  const ConstantMultipleLines1 = "this constant" +
   208      "is defined on multiple " +
   209      "lines"
   210  
   211  // ConstantMultipleLines2 tests a multiline comment with go multiline string.
   212  const ConstantMultipleLines2 = `this constant
   213  is defined on multiple
   214            lines
   215  `
   216  
   217  // Here is a constant block.  All constants are reported as a group.
   218  const (
   219      // ConstantGroup1 is a constant defined in a group.
   220      ConstantGroup1 = "constant 1"
   221  
   222      // ConstantGroup2 is a constant defined in a group.
   223      ConstantGroup2 = "constant 2"
   224  )
   225  
   226  // InterfaceType tests the documentation of interfaces.
   227  type InterfaceType interface {
   228      func(int) int
   229  }
   230  
   231  // StructureType tests the documentation of structures.
   232  type StructureType struct {
   233      // F1 is the first test field of the structure.
   234      F1 string
   235      // F2 is the second test field of the structure.
   236      F2 int
   237  }
   238  
   239  // GetF1 is a method to a structure.
   240  func (s *StructureType) GetF1(
   241      a, b, c int,
   242  ) string {
   243      const base10 = 10
   244  
   245      t := a + c + b
   246  
   247      return s.F1 + strconv.FormatInt(int64(t), base10)
   248  }
   249  
   250  // TimesTwo returns the value times two.
   251  func TimesTwo(i int) int {
   252      return i + i
   253  }
   254  
   255  // TimesThree returns the value times three.
   256  func TimesThree(i int) int {
   257      return i + i + i
   258  }
   259  ```
   260  <!--- gotomd::End::file::./example1.go -->
   261  
   262  or a single declaration:
   263  
   264  <!--- gotomd::Bgn::dcl::./TimesTwo -->
   265  ```go
   266  func TimesTwo(i int) int
   267  ```
   268  <!--- gotomd::End::dcl::./TimesTwo -->
   269  
   270  or a multiple declarations:
   271  
   272  <!--- gotomd::Bgn::dcl::./TimesTwo TimesThree -->
   273  ```go
   274  func TimesTwo(i int) int
   275  func TimesThree(i int) int
   276  ```
   277  <!--- gotomd::End::dcl::./TimesTwo TimesThree -->
   278  
   279  or a single declaration on a single-line:
   280  
   281  <!--- gotomd::Bgn::dcls::./TimesTwo -->
   282  ```go
   283  func TimesTwo(i int) int
   284  ```
   285  <!--- gotomd::End::dcls::./TimesTwo -->
   286  
   287  or a multiple declarations on a single-line:
   288  
   289  <!--- gotomd::Bgn::dcls::./TimesTwo TimesThree -->
   290  ```go
   291  func TimesTwo(i int) int
   292  func TimesThree(i int) int
   293  ```
   294  <!--- gotomd::End::dcls::./TimesTwo TimesThree -->
   295  
   296  or a natural declaration:
   297  
   298  <!--- gotomd::Bgn::dcln::./TimesTwo -->
   299  ```go
   300  // TimesTwo returns the value times two.
   301  func TimesTwo(i int) int
   302  ```
   303  <!--- gotomd::End::dcln::./TimesTwo -->
   304  
   305  or a multiple natural declarations:
   306  
   307  <!--- gotomd::Bgn::dcln::./TimesTwo TimesThree -->
   308  ```go
   309  // TimesTwo returns the value times two.
   310  func TimesTwo(i int) int
   311  
   312  // TimesThree returns the value times three.
   313  func TimesThree(i int) int
   314  ```
   315  <!--- gotomd::End::dcln::./TimesTwo TimesThree -->