[英]list emr clusters using go
I'm trying to list emr clusters using go.我正在尝试使用 go 列出 emr 集群。
Here is the code I have that is returning blank.这是我返回空白的代码。 I did "the same" in python with correct results.
我在 python 中做了“相同的”,结果正确。
running := "RUNNING"
waiting := "WAITING"
emr_states := []*string {&running, &waiting}
var abc emr.ListClustersInput
abc.SetClusterStates(emr_states)
sess := session.Must(session.NewSession())
svc := emr.New(sess)
list_clusters_output, err := svc.ListClusters(&abc)
_ = err
println(fmt.Sprintf("type of list clusters output is %s", reflect.TypeOf(list_clusters_output)))
println(fmt.Sprintf("type of *list clusters output is %s", reflect.TypeOf(*list_clusters_output)))
list_clusters_output_dereffed := *list_clusters_output
println(list_clusters_output_dereffed.String())
The output I'm getting is我得到的 output 是
type of list clusters output is *emr.ListClustersOutput
type of *list clusters output is emr.ListClustersOutput
{
}
There is a cluster running that I have successfully returned with a python script.我已经使用 python 脚本成功返回了一个正在运行的集群。
Figured it out.弄清楚了。 I was missing region indication in the session.
我在 session 中缺少区域指示。
Full solution below.下面的完整解决方案。
package main
import (
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/emr"
)
func main() {
starting := "STARTING"
running := "RUNNING"
waiting := "WAITING"
emr_states := []*string {&starting, &running, &waiting}
var abc emr.ListClustersInput
abc.SetClusterStates(emr_states)
sess := session.Must(session.NewSession())
reggie := "us-east-1"
sess.Config.Region = ®gie
svc := emr.New(sess)
list_clusters_output, err := svc.ListClusters(&abc)
if err != nil {
println(err.Error())
}
list_clusters_output_dereffed := *list_clusters_output
println(list_clusters_output_dereffed.GoString())
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.