code: func (u *DockerRegistryURL) UnmarshalJSON(data []byte) error {
  	// Using the alias type allows it to have all the same fields as the
  	// DockerRegistryURL but avoids a loop when marshalling since it will not
  	// have the same UnmarshalJSON method.
  	type Alias DockerRegistryURL
  	aux := &struct {
  		Userinfo string `json:",omitempty"`
  		*Alias
  	}{
  		Alias: (*Alias)(u),
  	}
  	if err := json.Unmarshal(data, &aux); err != nil {
  		return err
  	}
  	if aux.Userinfo == "" {
  		return nil
  	}
  	ui, err := url.Parse("http://" + aux.Userinfo + "@foo.com")
  	if err != nil {
  		return fmt.Errorf("error parsing userinfo: %s", err)
  	}
  	u.Userinfo = ui.User
  	return nil
  }
docs: // UnmarshalJSON implements unmarshalling which will maintain the url.Userinfo
  // details which are normally lost due to lack of exported fields.