func (r *Result) String() string {
	var str string
	if r.IP4 != nil {
		str = fmt.Sprintf("IP4:%+v, ", *r.IP4)
	}
	if r.IP6 != nil {
		str += fmt.Sprintf("IP6:%+v, ", *r.IP6)
	}
	return fmt.Sprintf("%sDNS:%+v", str, r.DNS)
}
String returns a formatted string in the form of "[IP4: $1,][ IP6: $2,] DNS: $3" where
$1 represents the receiver's IPv4, $2 represents the receiver's IPv6 and $3 the
receiver's DNS. If $1 or $2 are nil, they won't be present in the returned string.
package types020
import (
	"encoding/json"
	"fmt"
	"net"
	"os"
	"github.com/containernetworking/cni/pkg/types"
)
const ImplementedSpecVersion string = "0.2.0"
var SupportedVersions = []string{"", "0.1.0", ImplementedSpecVersion}
func NewResult(data []byte) (types.Result, error) {
	result := &Result{}
	if err := json.Unmarshal(data, result); err != nil {
		return nil, err
	}
	return result, nil
}
func GetResult(r types.Result) (*Result, error) {
	result020, err := r.GetAsVersion(ImplementedSpecVersion)
	if err != nil {
		return nil, err
	}
	result, ok := result020.(*Result)
	if !ok {
		return nil, fmt.Errorf("failed to convert result")
	}
	return result, nil
}
type Result struct {
	CNIVersion string    `json:"cniVersion,omitempty"`
	IP4        *IPConfig `json:"ip4,omitempty"`
	IP6        *IPConfig `json:"ip6,omitempty"`
	DNS        types.DNS `json:"dns,omitempty"`
}
func (r *Result) Version() string {
	return ImplementedSpecVersion
}
func (r *Result) GetAsVersion(version string) (types.Result, error) {
	for _, supportedVersion := range SupportedVersions {
		if version == supportedVersion {
			r.CNIVersion = version
			return r, nil
		}
	}
	return nil, fmt.Errorf("cannot convert version %q to %s", SupportedVersions, version)
}
func (r *Result) Print() error {
	data, err := json.MarshalIndent(r, "", "    ")
	if err != nil {
		return err
	}
	_, err = os.Stdout.Write(data)
	return err
}