sample.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. "BucketInventorySample": sample.BucketInventorySample,
  24. "ObjectACLSample": sample.ObjectACLSample,
  25. "ObjectMetaSample": sample.ObjectMetaSample,
  26. "ListObjectsSample": sample.ListObjectsSample,
  27. "DeleteObjectSample": sample.DeleteObjectSample,
  28. "AppendObjectSample": sample.AppendObjectSample,
  29. "CopyObjectSample": sample.CopyObjectSample,
  30. "PutObjectSample": sample.PutObjectSample,
  31. "GetObjectSample": sample.GetObjectSample,
  32. "CnameSample": sample.CnameSample,
  33. "SignURLSample": sample.SignURLSample,
  34. "ArchiveSample": sample.ArchiveSample,
  35. "ObjectTaggingSample": sample.ObjectTaggingSample,
  36. "BucketEncryptionSample": sample.BucketEncryptionSample,
  37. "SelectObjectSample": sample.SelectObjectSample,
  38. }
  39. func main() {
  40. var name string
  41. flag.StringVar(&name, "name", "", "Waiting for a sample of execution")
  42. flag.Parse()
  43. if len(name) <= 0 {
  44. fmt.Println("please enter your sample's name. like '-name CreateBucketSample'")
  45. os.Exit(-1)
  46. } else {
  47. if sampleMap[name] == nil {
  48. fmt.Println("the " + name + "is not exist.")
  49. os.Exit(-1)
  50. }
  51. sampleMap[name].(func())()
  52. }
  53. }