46 lines
603 B
Go
46 lines
603 B
Go
package testlib
|
|
|
|
import (
|
|
"io"
|
|
"time"
|
|
)
|
|
|
|
type Options struct {
|
|
|
|
// Foo is an option.
|
|
Foo int
|
|
|
|
// Bars, any number.
|
|
Bar []string
|
|
|
|
// Duration is another option.
|
|
Duration time.Duration
|
|
|
|
// Time is the third option here.
|
|
Time time.Time
|
|
}
|
|
|
|
type OptionWithHelp struct {
|
|
|
|
// Custom help.
|
|
Help bool
|
|
}
|
|
|
|
// Foo sums three numbers.
|
|
// It prints the sum to stdout.
|
|
//
|
|
// The input numbers can be any integer.
|
|
func Foo(a, b, c int) int {
|
|
return a + b + c
|
|
}
|
|
|
|
func Bar(out io.Writer, a, b, c int) int {
|
|
return a + b + c
|
|
}
|
|
|
|
func Baz(o Options) int {
|
|
return o.Foo
|
|
}
|
|
|
|
func CustomHelp(o OptionWithHelp) {}
|