I am having trouble using the go sdk to list all of the storage gateways in a region using the following code:
package main
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/storagegateway"
)
func newSess() (sess *session.Session) {
sess, err := session.NewSession(&aws.Config{
Region: aws.String("us-east-2"),
})
if err != nil {
fmt.Printf("Error creating session: %s
", err)
return
}
return sess
}
func main() {
sgw := storagegateway.New(newSess())
input := &storagegateway.ListGatewaysInput{
Limit: aws.Int64(5),
Marker: aws.String("1"),
}
result, err := sgw.ListGateways(input)
if err != nil {
fmt.Printf("Error listing gateways %s
", err)
return
}
fmt.Println(result)
}
My environment is the following:
- Go version: 1.9.2 darwin/amd64
- Operating system: macOS 10.13.2
- aws-sdk-go: v1.12.63
The SDK is using the default profile specified in ~/.aws/config
as it should and the credentials are correct as well. Furthermore, I am able to list the gateways using the awscli alone.
This could very well be something simple that I have overlooked as I am no expert. That said, any help would be greatly appreciated.