September 19, 2016

List Account VMs

Basic example showing how to get a list of Virtual Guests under an account
package main

import (


func main() {
  // Create a session, using credentials from the environment or a .softlayer file
    sess := session.New()

  // Get an instance of the Account service
    service := services.GetAccountService(sess)

  // invoke the GetVirtualGuests API method
    vms, err := service.Mask("id;hostname;domain").GetVirtualGuests()
    if err != nil {
        fmt.Printf("Error retrieving Virtual Guests from Account: %s\n", err)
    } else {
        fmt.Println("VMs under Account:")

    for _, vm := range vms {
      fmt.Printf("\t[%d]%s.%s\n", *vm.Id, *vm.Hostname, *vm.Domain)


If this article contains any error, or leaves any of your questions unanswered, please help us out by opening up a github issue.
Open an issue