[PATCH go-xml 4/4] doc: Make examples a complete program

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add `package main` and declare a `main()` function.

Signed-off-by: Philipp Hahn <hahn@xxxxxxxxxxxxx>
---
 doc.go | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/doc.go b/doc.go
index c4ce0dd..25bc1d5 100644
--- a/doc.go
+++ b/doc.go
@@ -33,30 +33,38 @@
 //
 // Example creating a domain XML document from configuration:
 //
+//  package main
+//
 //  import (
 //   "github.com/libvirt/libvirt-go-xml"
 //  )
 //
-//  domcfg := &libvirtxml.Domain{Type: "kvm", Name: "demo",
-//                               UUID: "8f99e332-06c4-463a-9099-330fb244e1b3",
-//                               ....}
-//  xmldoc, err := domcfg.Marshal()
+//  func main() {
+//    domcfg := &libvirtxml.Domain{Type: "kvm", Name: "demo",
+//                                 UUID: "8f99e332-06c4-463a-9099-330fb244e1b3",
+//                                 ....}
+//    xmldoc, err := domcfg.Marshal()
+//  }
 //
 // Example parsing a domainXML document, in combination with libvirt-go
 //
+//  package main
+//
 //  import (
 //    "github.com/libvirt/libvirt-go"
 //    "github.com/libvirt/libvirt-go-xml"
 //    "fmt"
 //  )
 //
-//  conn, err := libvirt.NewConnect("qemu:///system")
-//  dom, err := conn.LookupDomainByName("demo")
-//  xmldoc, err := dom.GetXMLDesc(0)
+//  func main() {
+//    conn, err := libvirt.NewConnect("qemu:///system")
+//    dom, err := conn.LookupDomainByName("demo")
+//    xmldoc, err := dom.GetXMLDesc(0)
 //
-//  domcfg := &libvirtxml.Domain{}
-//  err = domcfg.Unmarshal(xmldoc)
+//    domcfg := &libvirtxml.Domain{}
+//    err = domcfg.Unmarshal(xmldoc)
 //
-//  fmt.Printf("Virt type %s\n", domcfg.Type)
+//    fmt.Printf("Virt type %s\n", domcfg.Type)
+//  }
 //
 package libvirtxml
-- 
2.20.1


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux