Func output into a variable

I’m new to go, need a little help from the Gophers. Here is what I’m trying to do . I would like to put the below output of this func into a variable called “hmc_uuid”

func (s *Session) getManaged() {
// mgdurl := s.url + "/rest/api/uom/LogicalPartition"
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 {
} else {
	defer response.Body.Close()
	contents, err := ioutil.ReadAll(response.Body)
	if err != nil {
	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 {
	fmt.Printf("AtomID: %v\n", feed.Entry.Content.ManagementConsole.Metadata.Atom.AtomID)
	fmt.Printf("AtomCreated: %v\n", feed.Entry.Content.ManagementConsole.Metadata.Atom.AtomCreated)

little more info… trying to get the output of “AtomID” into a variable called " hmc_uuid”

What are the types for those 2 feeds?

In that case, your function should return those 2 as types. Assuming they are string, it is something like:

func UUID(...) (id, created string) {
        ...   // your codes here without those fmt.Printf
        return feed.Entry.Content.ManagementConsole.Metadata.Atom.AtomID, 

Then you can call the function and output it inside your own variables. Example:

uuid, time := UUID()

Welcome to Golang Bridge by the way! :rocket: :fireworks:

1 Like

Hello Holloway,
Thanks for the reply. Yes they are strings. So i would need to create a new func just to pass my first func output into a variable if I`m understanding this correctly?

oh and thanks man … I really like go