Skip to content

Conversation

docooler
Copy link

package main

import (
"fmt"
"github.com/moznion/go-netplan-types/v2"
yamlnillable "github.com/moznion/go-yaml-nillable"
"gopkg.in/yaml.v3"
)

func main() {
network := netplan.Network{
Network: &netplan.NetworkConfig{
Ethernets: netplan.Ethernets{
"eno1": &netplan.Ethernet{
Device: netplan.Device{
DHCP4: yamlnillable.BoolOf(true),
},
},
},
},
}
yamlString, _ := yaml.Marshal(&network)
fmt.Printf("%s\n", yamlString)
}

package main

import (
	"fmt"
	"github.com/moznion/go-netplan-types/v2"
	yamlnillable "github.com/moznion/go-yaml-nillable"
	"gopkg.in/yaml.v3"
)

func main() {
	network := netplan.Network{
		Network: &netplan.NetworkConfig{
			Ethernets: netplan.Ethernets{
				"eno1": &netplan.Ethernet{
					Device: netplan.Device{
						DHCP4: yamlnillable.BoolOf(true),
					},
				},
			},
		},
	}
	yamlString, _ := yaml.Marshal(&network)
	fmt.Printf("%s\n", yamlString)
}
@docooler
Copy link
Author

in yaml.v3 netplan.NetworkConfig will endless recursion when call Marshal. because this interface return itelf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant