sample.go 1.6 KB

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