sample.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // main of samples
  2. package main
  3. import (
  4. "flag"
  5. "fmt"
  6. "os"
  7. "github.com/aliyun/aliyun-oss-go-sdk/sample"
  8. )
  9. // sampleMap contains all samples
  10. var sampleMap = map[string]interface{}{
  11. "CreateBucketSample": sample.CreateBucketSample,
  12. "NewBucketSample": sample.NewBucketSample,
  13. "ListBucketsSample": sample.ListBucketsSample,
  14. "BucketACLSample": sample.BucketACLSample,
  15. "BucketLifecycleSample": sample.BucketLifecycleSample,
  16. "BucketRefererSample": sample.BucketRefererSample,
  17. "BucketLoggingSample": sample.BucketLoggingSample,
  18. "BucketWebsiteSample": sample.BucketWebsiteSample,
  19. "BucketCORSSample": sample.BucketCORSSample,
  20. "BucketPolicySample": sample.BucketPolicySample,
  21. "BucketrRequestPaymentSample": sample.BucketrRequestPaymentSample,
  22. "BucketQoSInfoSample": sample.BucketQoSInfoSample,
  23. "ObjectACLSample": sample.ObjectACLSample,
  24. "ObjectMetaSample": sample.ObjectMetaSample,
  25. "ListObjectsSample": sample.ListObjectsSample,
  26. "DeleteObjectSample": sample.DeleteObjectSample,
  27. "AppendObjectSample": sample.AppendObjectSample,
  28. "CopyObjectSample": sample.CopyObjectSample,
  29. "PutObjectSample": sample.PutObjectSample,
  30. "GetObjectSample": sample.GetObjectSample,
  31. "CnameSample": sample.CnameSample,
  32. "SignURLSample": sample.SignURLSample,
  33. "ArchiveSample": sample.ArchiveSample,
  34. "ObjectTaggingSample": sample.ObjectTaggingSample,
  35. "BucketEncryptionSample": sample.BucketEncryptionSample,
  36. "SelectObjectSample": sample.SelectObjectSample,
  37. }
  38. func main() {
  39. var name string
  40. flag.StringVar(&name, "name", "", "Waiting for a sample of execution")
  41. flag.Parse()
  42. if len(name) <= 0 {
  43. fmt.Println("please enter your sample's name. like '-name CreateBucketSample'")
  44. os.Exit(-1)
  45. } else {
  46. if sampleMap[name] == nil {
  47. fmt.Println("the " + name + "is not exist.")
  48. os.Exit(-1)
  49. }
  50. sampleMap[name].(func())()
  51. }
  52. }