Package example1
This project is used by the Szerszam utility function to test its markdown
update methods against an independent standalone project. All features
will be tested against this file so it will be updated and changed often.
The following will be replaced by the go package documentation
package example1
Package example1 exists in order to test various go to git
markdown (gToMD) extraction utilities. Various object will be defined that
exhibit the various comment and declaration options permitted by gofmt.
Heading
This paragraph will demonstrating further documentation under a "markdown"
header.
Declarations can be single-line or multi-line blocks or constructions. Each
type will be included here for complete testing.
Here we will add function documentation:
func TimesTwo(i int) int
TimesTwo returns the value times two.
and another:
func TimesThree(i int) int
TimesThree returns the value times three.
and the defined interface:
type InterfaceType interface {
func(int) int
}
InterfaceType tests the documentation of interfaces.
and the defined structure:
type StructureType struct {
// F1 is the first test field of the structure.
F1 string
// F2 is the second test field of the structure.
F2 int
}
StructureType tests the documentation of structures.
and run a specific test
go test -v -cover -run Test_PASS_Example1 .
$\small{\texttt{=== RUN Test̲PASS̲Example1}}$
$\small{\texttt{--- PASS: Test̲PASS̲Example1 (0.0s)}}$
$\small{\texttt{PASS}}$
$\small{\texttt{coverage: 100.0﹪ of statements}}$
$\small{\texttt{ok github.com/dancsecs/gotomd/example1 coverage: 100.0﹪ of statements}}$
or run all tests in a package:
go test -v -cover .
$\small{\texttt{=== RUN Test̲PASS̲Example1}}$
$\small{\texttt{--- PASS: Test̲PASS̲Example1 (0.0s)}}$
$\small{\texttt{=== RUN Test̲FAIL̲Example1}}$
$\small{\texttt{ example1̲test.go:29: unexpected int:}}$
$\small{\texttt{ \emph{2+2=5 (is true for big values of two)}:}}$
$\small{\texttt{ \color{magenta}GOT: \color{default}\color{darkturquoise}4\color{default}}}$
$\small{\texttt{ \color{cyan}WNT: \color{default}\color{darkturquoise}5\color{default}}}$
$\small{\texttt{ example1̲test.go:30: unexpected string:}}$
$\small{\texttt{ \color{magenta}GOT: \color{default}\color{green}New in Got\color{default} Similar in (\color{darkturquoise}1\color{default}) both}}$
$\small{\texttt{ \color{cyan}WNT: \color{default} Similar in (\color{darkturquoise}2\color{default}) both\color{red}, new in Wnt\color{default}}}$
$\small{\texttt{ example1̲test.go:36: Unexpected stdout Entry: got (1 lines) - want (1 lines)}}$
$\small{\texttt{ \color{darkturquoise}0\color{default}:\color{darkturquoise}0\color{default} This output line \color{red}is\color{default}\color{yellow}/\color{default}\color{green}will be\color{default} different}}$
$\small{\texttt{ example1̲test.go:40: unexpected string:}}$
$\small{\texttt{ \color{magenta}GOT: \color{default}\color{darkturquoise}Total\color{default}: 6}}$
$\small{\texttt{ \color{cyan}WNT: \color{default}\color{darkturquoise}Sum\color{default}: 6}}$
$\small{\texttt{--- FAIL: Test̲FAIL̲Example1 (0.0s)}}$
$\small{\texttt{FAIL}}$
$\small{\texttt{coverage: 100.0﹪ of statements}}$
$\small{\texttt{FAIL github.com/dancsecs/gotomd/example1 0.0s}}$
$\small{\texttt{FAIL}}$
or include a file
cat ./example1.go
// Package example1 exists in order to test various go to git
// markdown (gToMD) extraction utilities. Various object will be defined that
// exhibit the various comment and declaration options permitted by gofmt.
//
// # Heading
//
// This paragraph will demonstrating further documentation under a "markdown"
// header.
//
// Declarations can be single-line or multi-line blocks or constructions. Each
// type will be included here for complete testing.
package example1
import "strconv"
// ConstDeclSingleCmtSingle has a single-line comment.
const ConstDeclSingleCmtSingle = "single-line declaration and comment"
// ConstDeclSingleCmtMulti has a multiline
// comment.
const ConstDeclSingleCmtMulti = "single-line declaration and comment"
// ConstDeclMultiCmtSingle has a single-line comment with a multiline decl.
const ConstDeclMultiCmtSingle = `multiline constant
definition
`
// ConstDeclMultiCmtMulti has a multiline comment with
// a multiline decl.
const ConstDeclMultiCmtMulti = `multiline constant
definition
`
// ConstDeclConstrCmtSingle has a single-line comment with a multiline decl.
const ConstDeclConstrCmtSingle = `multiline constant` + "\n" +
ConstDeclMultiCmtSingle + " including other constants: \n" +
ConstDeclSingleCmtSingle + "\n" + `
=========end of constant=============
`
// ConstDeclConstrCmtMulti has a multiline comment with
// a multiline decl.
const ConstDeclConstrCmtMulti = `multiline constant` + "\n" +
ConstDeclMultiCmtSingle + " including other constants: \n" +
ConstDeclSingleCmtSingle + "\n" + `
=========end of constant=============
`
// ConstantSingleLine tests single line constant definitions.
const ConstantSingleLine = "this is defined on a single-line"
// ConstantMultipleLines1 test a multiline comment with string addition.
// Also with longer:
//
// multiline comments with spacing.
const ConstantMultipleLines1 = "this constant" +
"is defined on multiple " +
"lines"
// ConstantMultipleLines2 tests a multiline comment with go multiline string.
const ConstantMultipleLines2 = `this constant
is defined on multiple
lines
`
// Here is a constant block. All constants are reported as a group.
const (
// ConstantGroup1 is a constant defined in a group.
ConstantGroup1 = "constant 1"
// ConstantGroup2 is a constant defined in a group.
ConstantGroup2 = "constant 2"
)
// InterfaceType tests the documentation of interfaces.
type InterfaceType interface {
func(int) int
}
// StructureType tests the documentation of structures.
type StructureType struct {
// F1 is the first test field of the structure.
F1 string
// F2 is the second test field of the structure.
F2 int
}
// GetF1 is a method to a structure.
func (s *StructureType) GetF1(
a, b, c int,
) string {
const base10 = 10
t := a + c + b
return s.F1 + strconv.FormatInt(int64(t), base10)
}
// TimesTwo returns the value times two.
func TimesTwo(i int) int {
return i + i
}
// TimesThree returns the value times three.
func TimesThree(i int) int {
return i + i + i
}
or a single declaration:
func TimesTwo(i int) int
or a multiple declarations:
func TimesTwo(i int) int
func TimesThree(i int) int
or a single declaration on a single-line:
func TimesTwo(i int) int
or a multiple declarations on a single-line:
func TimesTwo(i int) int
func TimesThree(i int) int
or a natural declaration:
// TimesTwo returns the value times two.
func TimesTwo(i int) int
or a multiple natural declarations:
// TimesTwo returns the value times two.
func TimesTwo(i int) int
// TimesThree returns the value times three.
func TimesThree(i int) int