big tings
This commit is contained in:
30
template/codecs.go
Normal file
30
template/codecs.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package template
|
||||
|
||||
import "fmt"
|
||||
|
||||
// CodecType represents the type of codec used to encode/render a value
|
||||
type CodecType string
|
||||
|
||||
const (
|
||||
CodecText CodecType = "text"
|
||||
CodecNumber CodecType = "number"
|
||||
CodecYaml CodecType = "yaml"
|
||||
CodecList CodecType = "list"
|
||||
CodecConst CodecType = "const"
|
||||
)
|
||||
|
||||
func parseCodecType(input string) (CodecType, error) {
|
||||
switch input {
|
||||
case "number":
|
||||
return CodecNumber, nil
|
||||
case "yaml":
|
||||
return CodecYaml, nil
|
||||
case "list":
|
||||
return CodecList, nil
|
||||
case "text":
|
||||
return CodecText, nil
|
||||
case "const":
|
||||
return CodecConst, nil
|
||||
}
|
||||
return CodecText, fmt.Errorf("unknown codec: '%s'", input)
|
||||
}
|
Reference in New Issue
Block a user