Last active
August 29, 2015 14:22
-
-
Save MacoTasu/7ce1f00d434fe72e0710 to your computer and use it in GitHub Desktop.
intaractve select bucket
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getBucket(svc *s3.S3) string { | |
» var param *s3.ListBucketsInput | |
» resp, err := svc.ListBuckets(param) | |
» if err != nil { | |
» » assert(err) | |
» } | |
» var buckets []string | |
» for index, b := range resp.Buckets { | |
» » fmt.Println(fmt.Sprintf(" * [%d]: %s", index, *b.Name)) | |
» » buckets = append(buckets, *b.Name) | |
» } | |
» scanner := bufio.NewScanner(os.Stdin) | |
» fmt.Print("バケットを番号で指定してください-> ") | |
» scanner.Scan() | |
» argIndex := scanner.Text() | |
» index, err := strconv.Atoi(argIndex) | |
» if err != nil { | |
» » assert(err) | |
» } | |
» bucketName := buckets[index] | |
» fmt.Printf(bucketName) | |
» return bucketName | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment