2 * Copyright (c) 2018 ZTE Corporation.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * and the Apache License 2.0 which both accompany this distribution,
6 * and are available at http://www.eclipse.org/legal/epl-v10.html
7 * and http://www.apache.org/licenses/LICENSE-2.0
10 * ZTE - initial Project
20 * F int `yaml:"a, omitempty"`
24 * yaml.Marshal(&T{B:2}) /// returns "b: 2 \n"
25 * yaml.Marshal(&T{F:1}) // returns "a: 1 \nb: 0\n"
27 func MarshalYaml(in interface{}) (string, error) {
28 b, err := yaml.Marshal(in)
38 * yaml.Unmarshal([]byte("a: 1\nb: 2"), &t)
41 func UnmarshalYaml(str string, out interface{}) error {
42 return yaml.Unmarshal([]byte(str), out)