feed.Entry undefined (type Feed has no field or method Entry)

Hello Gophers,
I’m kinda new to go and I cant seems to get my head around this error message
“feed.Entry undefined (type Feed has no field or method Entry)” I have pasted my code below can someone help a fellow Gopher?

thanks peeps

package main

import (
	"bytes"
	"crypto/tls"
	"encoding/xml"
	"flag"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"net/http/cookiejar"
	"text/template"
)

//
// XML parsing structures
//

type Feed struct {
	XMLName xml.Name `xml:"feed"`
	Entries []Entry `xml:"entry"`
}
type Entry struct {
	XMLName  xml.Name  `xml:"entry"`
	Contents []Content `xml:"content"`
}

type Content struct {
	XMLName xml.Name           `xml:"content"`
	Lpar    []LogicalPartition `xml:"http://www.ibm.com/xmlns/systems/power/firmware/uom/mc/2012_10/ LogicalPartition"`
	//	Console []ManagementConsole `xml:"http://www.ibm.com/xmlns/systems/power/firmware/uom/mc/2012_10/ Managementconsole"`
}

type LogicalPartition struct {
	XMLName       xml.Name `xml:"http://www.ibm.com/xmlns/systems/power/firmware/uom/mc/2012_10/ LogicalPartition"`
	PartitionName string
	PartitionID   int
	PartitionUUID string
}
type ManagementConsole struct {
	XMLName xml.Name `xml:"ManagementConsole"`
	HMCUUID string
}

type Metadata struct {
	XMLName xml.Name `xml:"Metadata"`
}

type atom struct {
	XMLName xml.Name `xml:"Atom"`
	AtomID  string   `xml:"AtomID"`
}

//
// HTTP session struct
//

type Session struct {
	client   *http.Client
	User     string
	Password string
	url      string
}

func NewSession(user string, password string, url string) *Session {
	tr := &http.Transport{
		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
	}

	jar, err := cookiejar.New(nil)
	if err != nil {
		log.Fatal(err)
	}

	return &Session{client: &http.Client{Transport: tr, Jar: jar}, User: user, Password: password, url: url}
}

func (s *Session) doLogon() {

	authurl := s.url + "/rest/api/web/Logon"

	// template for login request
	logintemplate := `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  <LogonRequest xmlns="http://www.ibm.com/xmlns/systems/power/firmware/web/mc/2012_10/" schemaVersion="V1_1_0">
    <Metadata>
      <Atom/>
    </Metadata>
    <UserID kb="CUR" kxe="false">{{.User}}</UserID>
    <Password kb="CUR" kxe="false">{{.Password}}</Password>
  </LogonRequest>`

	tmpl := template.New("logintemplate")
	tmpl.Parse(logintemplate)
	authrequest := new(bytes.Buffer)
	err := tmpl.Execute(authrequest, s)
	if err != nil {
		log.Fatal(err)
	}

	request, err := http.NewRequest("PUT", authurl, authrequest)

	// set request headers
	request.Header.Set("Content-Type", "application/vnd.ibm.powervm.web+xml; type=LogonRequest")
	request.Header.Set("Accept", "application/vnd.ibm.powervm.web+xml; type=LogonResponse")
	request.Header.Set("X-Audit-Memento", "hmctest")

	response, err := s.client.Do(request)
	if err != nil {
		log.Fatal(err)
	} else {
		defer response.Body.Close()
		if response.StatusCode != 200 {
			log.Fatalf("Error status code: %d", response.StatusCode)
		}
	}
}

func (s *Session) lpar() {
	mgdurl := s.url + "/rest/api/uom/LogicalPartition"
	request, err := http.NewRequest("GET", mgdurl, nil)

	request.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")

	response, err := s.client.Do(request)
	if err != nil {
		log.Fatal(err)
	} else {
		defer response.Body.Close()
		contents, err := ioutil.ReadAll(response.Body)
		if err != nil {
			log.Fatal(err)
		}

		if response.StatusCode != 200 {
			log.Fatalf("Error getting LPAR informations. status code: %d", response.StatusCode)
		}

		var feed Feed
		new_err := xml.Unmarshal(contents, &feed)

		if new_err != nil {
			log.Fatal(new_err)
		}

		fmt.Printf("\t%-10s\t%-40s \n", "partition", "UUID")
		for _, entry := range feed.Entries {
			for _, content := range entry.Contents {
				for _, lpar := range content.Lpar {
					fmt.Printf("\t%-10s\t%-40s \n", lpar.PartitionName, lpar.PartitionUUID)
				}
			}
		}
	}
}

func (s *Session) getManaged() {
	mgdurl := s.url + "/rest/api/uom/ManagementConsole"
	request, err := http.NewRequest("GET", mgdurl, nil)
	request.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
	response, err := s.client.Do(request)
	if err != nil {
		log.Fatal(err)
	} else {
		defer response.Body.Close()
		contents, err := ioutil.ReadAll(response.Body)
		if err != nil {
			log.Fatal(err)
		}
		if response.StatusCode != 200 {
			log.Fatalf("Error getting HmcUUID informations. status code: %d", response.StatusCode)
		}
		var feed Feed
		new_err := xml.Unmarshal(contents, &feed)
		if new_err != nil {
			log.Fatal(new_err)
		}
		fmt.Printf("AtomID: %v\n", feed.Entry.Content.ManagementConsole.Metadata.Atom.AtomID)
		//fmt.Printf("AtomCreated: %v\n", feed.Entry.Content.ManagementConsole.Metadata.Atom.AtomCreated)

	}

}

The type Feed has an Entries field, but not an Entry.

Hello NobbZ,
Not sure I get what your saying here

Your code tries to access the Entry field of a variable that has type Feed. But the type Feed has no field Entry, but Entries only.

Compare the end of lpar with the end of getManaged.

In both you create the variable feed and use UnMarshal to fill it with values. But in lpar you correctly loop through the collection of feed.Entries, whereas in getManaged you incorrectly (because the field feed.Entry does not exist) try to refer to a single entry in the feed.

You need to write the end of getManaged to handle the collection in feed.Entries. (Notice you also try to access a single Content in the non-existing feed.Entry field - again, an Entry holds a collection of Contents, not a single content.)

@pcl ok I think I got what your saying. Thanks a ton for the direction. I will work on this right now