Code review comment for lp:~rogpeppe/goyaml/goyaml-rune-changes

Revision history for this message
Roger Peppe (rogpeppe) wrote :

Reviewers: mp+85889_code.launchpad.net,

Message:
Please take a look.

Description:
gofix + rune conversion.

https://code.launchpad.net/~rogpeppe/goyaml/goyaml-rune-changes/+merge/85889

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/5496045/

Affected files:
   M encode.go
   M goyaml.go
   M resolve.go

Index: encode.go
=== <email address hidden> >
<email address hidden>
=== modified file 'encode.go'
--- encode.go 2011-11-24 19:47:20 +0000
+++ encode.go 2011-12-15 15:22:49 +0000
@@ -223,18 +223,18 @@
  }

  func (e *encoder) intv(tag string, in reflect.Value) {
- s := strconv.Itoa64(in.Int())
+ s := strconv.FormatInt(in.Int(), 10)
   e.emitScalar(s, "", tag, C.YAML_PLAIN_SCALAR_STYLE)
  }

  func (e *encoder) uintv(tag string, in reflect.Value) {
- s := strconv.Uitoa64(in.Uint())
+ s := strconv.FormatUint(in.Uint(), 10)
   e.emitScalar(s, "", tag, C.YAML_PLAIN_SCALAR_STYLE)
  }

  func (e *encoder) floatv(tag string, in reflect.Value) {
   // FIXME: Handle 64 bits here.
- s := strconv.Ftoa32(float32(in.Float()), 'g', -1)
+ s := strconv.FormatFloat(float64(in.Float()), 'g', -1, 32)
   switch s {
   case "+Inf":
    s = ".inf"

Index: goyaml.go
=== <email address hidden> >
<email address hidden>
=== modified file 'goyaml.go'
--- goyaml.go 2011-11-24 19:50:00 +0000
+++ goyaml.go 2011-12-15 15:22:49 +0000
@@ -197,9 +197,9 @@
     recommend := tag[:s]
     for _, c := range tag[s+1:] {
      switch c {
- case int('c'):
+ case rune('c'):
       recommend += ",omitempty"
- case int('f'):
+ case rune('f'):
       recommend += ",flow"
      default:
       msg := fmt.Sprintf("Unsupported flag %q in tag %q of type %s",
string([]byte{uint8(c)}), tag, st)

Index: resolve.go
=== <email address hidden> >
<email address hidden>
=== modified file 'resolve.go'
--- resolve.go 2011-11-24 19:47:20 +0000
+++ resolve.go 2011-12-15 15:22:49 +0000
@@ -106,11 +106,11 @@

   case '.':
    // Not in the map, so maybe a normal float.
- floatv, err := strconv.Atof64(in)
+ floatv, err := strconv.ParseFloat(in, 64)
    if err == nil {
     return "!!float", floatv
    }
- // XXX Handle base 60 floats here (WTF!)
+ // XXX Handle base 60 floats here (WTF!)

   case 'D', 'S':
    // Int, float, or timestamp.
@@ -120,7 +120,7 @@
      break
     }
    }
- intv, err := strconv.Btoi64(in, 0)
+ intv, err := strconv.ParseInt(in, 0, 64)
    if err == nil {
     if intv == int64(int(intv)) {
      return "!!int", int(intv)
@@ -128,22 +128,22 @@
      return "!!int", intv
     }
    }
- floatv, err := strconv.Atof64(in)
+ floatv, err := strconv.ParseFloat(in, 64)
    if err == nil {
     return "!!float", floatv
    }
    if strings.HasPrefix(in, "0b") {
- intv, err := strconv.Btoi64(in[2:], 2)
+ intv, err := strconv.ParseInt(in[2:], 2, 64)
     if err == nil {
      return "!!int", int(intv)
     }
    } else if strings.HasPrefix(in, "-0b") {
- intv, err := strconv.Btoi64(in[3:], 2)
+ intv, err := strconv.ParseInt(in[3:], 2, 64)
     if err == nil {
      return "!!int", -int(intv)
     }
    }
- // XXX Handle timestamps here.
+ // XXX Handle timestamps here.

   case '<':
    // XXX Handle merge (<<) here.

« Back to merge proposal