package formatters
import (
"fmt"
"strings"
)
type Formatter interface {
Serialise(v interface{}) string
}
func NewFormatter(format string) Formatter {
format = strings.TrimSpace(strings.ToLower(format))
switch format {
case "json", "":
return NewJSONFormatter()
case "yaml", "yml":
return NewYAMLFormatter()
case "table", "markdown", "csv", "html":
return NewTableFormatter(format)
case "interactive":
return NewInteractiveFormatter()
default:
panic(fmt.Sprintf("the specified format [%s] is not supported!", format))
}
}
|
The pages are generated with Golds v0.3.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |