Skip to content

Commit

Permalink
Marshaler and Unmarshler is not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Songmu committed Jul 12, 2016
1 parent 5875a7a commit 6737863
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 26 deletions.
12 changes: 0 additions & 12 deletions decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ import (
"strings"
)

// Unmarshaler is the interface implemented by types that can unmarshal a ltsv
type Unmarshaler interface {
UnmarshalLTSV([]byte) error
}

// UnmarshalError is an error type for Unmarshal()
type UnmarshalError map[string]error

Expand Down Expand Up @@ -147,13 +142,6 @@ func Unmarshal(data []byte, v interface{}) error {
}
fv.SetFloat(n)
case reflect.Interface:
if u, ok := fv.Interface().(Unmarshaler); ok {
err := u.UnmarshalLTSV([]byte(s))
if err != nil {
errs[ft.Name] = err
}
continue
}
if tu, ok := fv.Interface().(encoding.TextUnmarshaler); ok {
err := tu.UnmarshalText([]byte(s))
if err != nil {
Expand Down
14 changes: 0 additions & 14 deletions encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ import (
"strings"
)

// Marshaler is the interface inmpemented by types that can marshal themselves
type Marshaler interface {
MarshalLTSV() ([]byte, error)
}

// MarshalError is an error type for Marshal()
type MarshalError map[string]error

Expand Down Expand Up @@ -103,15 +98,6 @@ func Marshal(v interface{}) ([]byte, error) {
case reflect.Float32, reflect.Float64:
arr = append(arr, key+":"+strconv.FormatFloat(fv.Float(), 'f', -1, fv.Type().Bits()))
case reflect.Interface:
if u, ok := fv.Interface().(Marshaler); ok {
buf, err := u.MarshalLTSV()
if err != nil {
errs[ft.Name] = err
} else {
arr = append(arr, key+":"+string(buf))
}
continue
}
if u, ok := fv.Interface().(encoding.TextMarshaler); ok {
buf, err := u.MarshalText()
if err != nil {
Expand Down

0 comments on commit 6737863

Please sign in to comment.