unmarshal "" into a *string leaves it as nil instead of an empty string

Bug #1231535 reported by Nate Finch
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
goyaml
New
Undecided
Unassigned

Bug Description

package main

import "launchpad.net/goyaml"
import "fmt"

func main() {
 s := ""
 mp := &s
 data, _ := goyaml.Marshal(mp)
 fmt.Printf("%s\n", string(data))
 var s2 *string
 goyaml.Unmarshal(data, &s2)
 if s2 != nil {
  fmt.Printf("%v, %q\n", s2, *s2)
 } else {
  fmt.Printf("%v\n", s2)
 }
}

actual output:
""

<nil>

expected output:
""

0xc20003b1c0, ""

Nate Finch (natefinch)
summary: - unmarshal "" into a *string leaves it as nil instead of am empty string
+ unmarshal "" into a *string leaves it as nil instead of an empty string
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.