Black Lives Matter. Support the Equal Justice Initiative.

Package pkg

import "cmd/doc/testdata"
Overview
Index

Overview ▾

Package comment.

Constants

Comment about block of constants.

const (
    // Comment before ConstOne.
    ConstOne = 1
    ConstTwo = 2 // Comment on line with ConstTwo.

)

Const block where first entry is unexported.

const (
    ConstFive
    ConstSix
)
const (
    ConstLeft2 uint64
    _, ConstRight3
    ConstLeft4, ConstRight4
)
const (
    ConstGroup1 unexportedType = iota
    ConstGroup2
    ConstGroup3
)

For case matching.

const CaseMatch = 1
const Casematch = 2
const (
    Duplicate = iota
)

Comment about exported constant.

const ExportedConstant = 1

Constants tied to unexportedType.

const (
    ExportedTypedConstant_unexported unexportedType = iota
)
const MultiLineConst = `
    MultiLineString1
    MultiLineString2
    MultiLineString3
`

Variables

Comment about block of variables.

var (
    // Comment before VarOne.
    VarOne = 1
    VarTwo = 2 // Comment on line with VarTwo.

)
var ExportedVarOfUnExported unexportedType

Comment about exported variable.

var ExportedVariable = 1
var LongLine = newLongLine(
    "someArgument1",
    "someArgument2",
    "someArgument3",
    "someArgument4",
    "someArgument5",
    "someArgument6",
    "someArgument7",
    "someArgument8",
)
var MultiLineVar = map[struct {
    MultiLineField1 string
    MultiLineField2 uint64
}]struct {
    MultiLineField3 error
    MultiLineField2 error
}{
    {"FieldVal1", 1}: {},
    {"FieldVal2", 2}: {},
    {"FieldVal3", 3}: {},
}

Var block where first entry is unexported.

var (
    VarFive = 5
)

func ExportedFormattedDoc

func ExportedFormattedDoc(a int) bool

Comment about exported function with formatting.

Example

fmt.Println(FormattedDoc())

Text after pre-formatted block.

func ExportedFunc

func ExportedFunc(a int) bool

Comment about exported function.

func MultiLineFunc

func MultiLineFunc(x interface {
    MultiLineMethod1() int
    MultiLineMethod2() int
    MultiLineMethod3() int
}) (r struct {
    MultiLineField1 int
    MultiLineField2 int
    MultiLineField3 int
})

func ReturnUnexported

func ReturnUnexported() unexportedType

type ExportedFormattedType

type ExportedFormattedType struct {
    // Comment before exported field with formatting.
    //
    // Example
    //
    //	a.ExportedField = 123
    //
    // Text after pre-formatted block.
    ExportedField int
}

type ExportedInterface

Comment about exported interface.

type ExportedInterface interface {
    // Comment before exported method.
    //
    //	// Code block showing how to use ExportedMethod
    //	func DoSomething() error {
    //		ExportedMethod()
    //		return nil
    //	}
    //
    ExportedMethod() // Comment on line with exported method.

    io.Reader // Comment on line with embedded Reader.
    error     // Comment on line with embedded error.
    // contains filtered or unexported methods
}

type ExportedStructOneField

type ExportedStructOneField struct {
    OnlyField int // the only field
}

type ExportedType

Comment about exported type.

type ExportedType struct {
    // Comment before exported field.
    ExportedField int // Comment on line with exported field.

    ExportedEmbeddedType            // Comment on line with exported embedded field.
    *ExportedEmbeddedType           // Comment on line with exported embedded *field.
    *qualified.ExportedEmbeddedType // Comment on line with exported embedded *selector.field.

    io.Reader // Comment on line with embedded Reader.
    // contains filtered or unexported fields
}
const ConstGroup4 ExportedType = ExportedType{}

Constants tied to ExportedType. (The type is a struct so this isn't valid Go, but it parses and that's all we need.)

const (
    ExportedTypedConstant ExportedType = iota
)

func ExportedTypeConstructor

func ExportedTypeConstructor() *ExportedType

Comment about constructor for exported type.

func ReturnExported

func ReturnExported() ExportedType

func (ExportedType) ExportedMethod

func (ExportedType) ExportedMethod(a int) bool

Comment about exported method.

func (ExportedType) Uncommented

func (ExportedType) Uncommented(a int) bool

type T1

type T1 = T2

type T2

type T2 int