AWS SDK for Go
Developer Guide

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

Listing Your Amazon SNS Topics

The following example lists the ARNs of your Amazon SNS topics in your default region.

package main import ( "" "" "fmt" "os" ) func main() { // Initialize a session that the SDK will use to load // credentials from the shared credentials file. (~/.aws/credentials). sess := session.Must(session.NewSessionWithOptions(session.Options{ SharedConfigState: session.SharedConfigEnable, })) svc := sns.New(sess) result, err := svc.ListTopics(nil) if err != nil { fmt.Println(err.Error()) os.Exit(1) } for _, t := range result.Topics { fmt.Println(*t.TopicArn) } }

See the complete example on GitHub.