Giter Club home page Giter Club logo

govmx's Introduction

GoVMX

![Gitter](https://badges.gitter.im/Join Chat.svg) GoDoc Build Status

Data encoding and decoding library for VMware VMX files.

Encoding

type VM struct {
	Encoding     string `vmx:".encoding"`
	Annotation   string `vmx:"annotation"`
	Hwversion    uint8  `vmx:"virtualHW.version"`
	HwProdCompat string `vmx:"virtualHW.productCompatibility"`
	Memsize      uint   `vmx:"memsize"`
	Numvcpus     uint   `vmx:"numvcpus"`
	MemHotAdd    bool   `vmx:"mem.hotadd"`
	DisplayName  string `vmx:"displayName"`
	GuestOS      string `vmx:"guestOS"`
	Autoanswer   bool   `vmx:"msg.autoAnswer"`
}

vm := new(VM)
vm.Encoding = "utf-8"
vm.Annotation = "Test VM"
vm.Hwversion = 10
vm.HwProdCompat = "hosted"
vm.Memsize = 1024
vm.Numvcpus = 2
vm.MemHotAdd = false
vm.DisplayName = "test"
vm.GuestOS = "other3xlinux-64"
vm.Autoanswer = true

data, err := Marshal(vm)

data should be:

.encoding = "utf-8"
annotation = "Test VM"
virtualHW.version = "10"
virtualHW.productCompatibility = "hosted"
memsize = "1024"
numvcpus = "2"
mem.hotadd = "false"
displayName = "test"
guestOS = "other3xlinux-64"
msg.autoAnswer = "true"

Decoding

var data = `.encoding = "utf-8"
annotation = "Test VM"
virtualHW.version = "10"
virtualHW.productCompatibility = "hosted"
memsize = "1024"
numvcpus = "2"
mem.hotadd = "false"
displayName = "test"
guestOS = "other3xlinux-64"
msg.autoAnswer = "true"
`

type VM struct {
	Encoding     string `vmx:".encoding"`
	Annotation   string `vmx:"annotation"`
	Hwversion    uint8  `vmx:"virtualHW.version"`
	HwProdCompat string `vmx:"virtualHW.productCompatibility"`
	Memsize      uint   `vmx:"memsize"`
	Numvcpus     uint   `vmx:"numvcpus"`
	MemHotAdd    bool   `vmx:"mem.hotadd"`
	DisplayName  string `vmx:"displayName"`
	GuestOS      string `vmx:"guestOS"`
	Autoanswer   bool   `vmx:"msg.autoAnswer"`
}

vm := new(VM)
err := Unmarshal([]byte(data), vm)

govmx's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.