sample.go 1.7 KB

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