Add missing comments

This commit is contained in:
Álvaro 2018-03-08 20:17:07 +00:00
parent 60ace443ec
commit 7aaf68cd58
2 changed files with 8 additions and 4 deletions

View File

@ -65,10 +65,12 @@ func (g *Generator) buildJSONMethods(runs [][]Value, typeName string, runsThresh
// Arguments to format are:
// [1]: type name
const textMethods = `
// MarshalText implements the encoding.TextMarshaler interface for %[1]s
func (i %[1]s) MarshalText() ([]byte, error) {
return []byte(i.String()), nil
}
// MarshalText implements the encoding.TextUnmarshaler interface for %[1]s
func (i *%[1]s) UnmarshalText(text []byte) error {
var err error
*i, err = %[1]sString(string(text))
@ -83,12 +85,12 @@ func (g *Generator) buildTextMethods(runs [][]Value, typeName string, runsThresh
// Arguments to format are:
// [1]: type name
const yamlMethods = `
// MarshalYAML implements a YAML Marshaler interface for %[1]s
// MarshalYAML implements a YAML Marshaler for %[1]s
func (i %[1]s) MarshalYAML() (interface{}, error) {
return i.String(), nil
}
// UnmarshalYAML implements a YAML Unmarshaler interface for %[1]s
// UnmarshalYAML implements a YAML Unmarshaler for %[1]s
func (i *%[1]s) UnmarshalYAML(unmarshal func(interface{}) error) error {
var s string
if err := unmarshal(&s); err != nil {

View File

@ -531,10 +531,12 @@ func PrimeString(s string) (Prime, error) {
return 0, fmt.Errorf("%s does not belong to Prime values", s)
}
// MarshalText implements the encoding.TextMarshaler interface for Prime
func (i Prime) MarshalText() ([]byte, error) {
return []byte(i.String()), nil
}
// MarshalText implements the encoding.TextUnmarshaler interface for Prime
func (i *Prime) UnmarshalText(text []byte) error {
var err error
*i, err = PrimeString(string(text))
@ -612,12 +614,12 @@ func PrimeString(s string) (Prime, error) {
return 0, fmt.Errorf("%s does not belong to Prime values", s)
}
// MarshalYAML implements a YAML Marshaler interface for Prime
// MarshalYAML implements a YAML Marshaler for Prime
func (i Prime) MarshalYAML() (interface{}, error) {
return i.String(), nil
}
// UnmarshalYAML implements a YAML Unmarshaler interface for Prime
// UnmarshalYAML implements a YAML Unmarshaler for Prime
func (i *Prime) UnmarshalYAML(unmarshal func(interface{}) error) error {
var s string
if err := unmarshal(&s); err != nil {