blob: c552629b26e036cb473341a8d35f0eb22da8f380 [file]
# package pkg
Package pkg has every form of declaration.
### Heading {#hdr-Heading}
Search [Google](https://google.com) for details.
### Links {#hdr-Links}
- pkgsite repo, [https://go.googlesource.com/pkgsite](https://go.googlesource.com/pkgsite)
- Play with Go, [https://play-with-go.dev](https://play-with-go.dev)
#### Example
```go
{
fmt.Println("Package example")
}
```
Output:
```
Package example
```
## Constants
```go
const (
X = 1
Y = 2
)
```
Several constants.
```go
const C = 1
```
C is a shorthand for 1.
## Variables
```go
var V = 2
```
V is a variable.
## Functions
```go
func Add(x int) int
```
Add adds 1 to x.
```go
func F()
```
F is a function.
#### Example
```go
{
pkg.F()
fmt.Println("F example")
}
```
Output:
```
F example
```
#### Example (second)
```go
{
pkg.F()
fmt.Println("F second example")
}
```
Output:
```
F second example
```
## Types
```go
type A int
```
```go
type B bool
```
```go
type I1 interface {
M1()
}
```
I1 is an interface.
```go
type I2 interface {
I1
M2()
}
```
```go
type S1 struct {
F int // field
}
```
S1 is a struct.
```go
type S2 struct {
S1
G int
}
```
S2 is another struct.
```go
type T int
```
T is a type.
#### Example
```go
{
_ = pkg.T(0)
fmt.Println("T example")
}
```
Output:
```
T example
```
```go
const CT T = 3
```
CT is a typed constant. They appear after their type.
```go
func TF() T
```
TF is a constructor for T.
```go
func (T) M()
```
M is a method of T. BUG(xxx): this verifies that notes are rendered.
#### Example
```go
{
var t pkg.T
t.M()
fmt.Println("M example")
}
```
Output:
```
M example
```