mitchellh/goamz — pull request #42 by henrysher (2014-05-09 07:01:23+00:00)
Title: add the API "CancelSpotRequests" with code cleanup via "go fmt"

@mitchellh

I have added the API "CancelSpotRequests" also with code cleanup via "go fmt" this time.
```go
package main

import (
"fmt"
"github.com/mitchellh/goamz/aws"
"github.com/mitchellh/goamz/ec2"
)

func main() {
auth, err := aws.EnvAuth()
if err != nil {
fmt.Print(err)
return
}
e := ec2.New(auth, aws.USEast)
options := ec2.RequestSpotInstances{
SpotPrice: "0.001",
ImageId: "ami-ccf405a5", // Ubuntu Maverick, i386, EBS store
InstanceType: "m1.small",
}
resp, err := e.RequestSpotInstances(&options)
if err != nil {
fmt.Print(err)
return
}
spotRequest := resp.SpotRequestResults[0]
spotId := []string{spotRequest.SpotRequestId}
fmt.Println("New created Spot Request Id:", spotId)
resp2, err := e.CancelSpotRequests(spotId)
if err != nil {
fmt.Print(err)
return
}
spotResult := resp2.CancelSpotRequestResults[0]
fmt.Println("Spot Request Id [", spotResult.SpotRequestId, "] State:", spotResult.State)
}
```