File tree 1 file changed +9
-16
lines changed
1 file changed +9
-16
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package version
2
2
3
3
import (
4
4
"bytes"
5
- "encoding/json"
6
5
"fmt"
7
6
"reflect"
8
7
"regexp"
@@ -390,25 +389,19 @@ func (v *Version) Original() string {
390
389
return v .original
391
390
}
392
391
393
- // UnmarshalJSON implements JSON.Unmarshaler interface.
394
- func (v * Version ) UnmarshalJSON (b []byte ) error {
395
- var s string
396
- if err := json .Unmarshal (b , & s ); err != nil {
397
- return err
398
- }
399
- temp , err := NewVersion (s )
392
+ // UnmarshalText implements encoding.TextUnmarshaler interface.
393
+ func (v * Version ) UnmarshalText (b []byte ) error {
394
+ temp , err := NewVersion (string (b ))
400
395
if err != nil {
401
396
return err
402
397
}
403
- v .metadata = temp .metadata
404
- v .pre = temp .pre
405
- v .segments = temp .segments
406
- v .si = temp .si
407
- v .original = temp .original
398
+
399
+ * v = * temp
400
+
408
401
return nil
409
402
}
410
403
411
- // MarshalJSON implements JSON.Marshaler interface.
412
- func (v Version ) MarshalJSON () ([]byte , error ) {
413
- return json . Marshal (v .String ())
404
+ // MarshalText implements encoding.TextMarshaler interface.
405
+ func (v * Version ) MarshalText () ([]byte , error ) {
406
+ return [] byte (v .String ()), nil
414
407
}
You can’t perform that action at this time.
0 commit comments