ເປັນຕົວຢ່າງການນຳໃຊ້ CreateObject ໃນ Go
Namespace/Package Name: github.com/go-ole/com
func Example_msxml_rssreader() { com.CoInitialize() defer com.CoUninitialize() var unknown *iunknown.Unknown var xmlhttp *Dispatch err := com.CreateObject("Microsoft.XMLHTTP", &unknown) unknown.QueryInterface(com.IDispatchInterfaceID, &xmlhttp) defer xmlhttp.Release() MustCallMethod(xmlhttp, "open", "GET", "http://rss.slashdot.org/Slashdot/slashdot", false) MustCallMethod(xmlhttp, "send", nil) state := -1 for state != 4 { state = int(MustGetProperty(xmlhttp, "readyState").Val) time.Sleep(10000000) } responseXml := MustGetProperty(xmlhttp, "responseXml").ToIDispatch() items := MustCallMethod(responseXml, "selectNodes", "/rss/channel/item").ToIDispatch() defer items.Release() length := int(MustGetProperty(items, "length").Val) for n := 0; n < length; n++ { item := MustGetProperty(items, "item", n).ToIDispatch() title := MustCallMethod(item, "selectSingleNode", "title").ToIDispatch() link := MustCallMethod(item, "selectSingleNode", "link").ToIDispatch() fmt.Println(MustGetProperty(title, "text").ToString()) fmt.Println(" " + MustGetProperty(link, "text").ToString()) title.Release() link.Release() item.Release() } }