在运行以下代码时:

  1. $ go run ks3.go

直接报错了:

  1. ks3.go:4:5: no required module provides package github.com/ks3sdklib/aws-sdk-go/aws: go.mod file not found in current directory or any parent directory; see 'go help modules'
  2. ks3.go:5:5: no required module provides package github.com/ks3sdklib/aws-sdk-go/aws/credentials: go.mod file not found in current directory or any parent directory; see 'go help modules'
  3. ks3.go:6:5: no required module provides package github.com/ks3sdklib/aws-sdk-go/service/s3: go.mod file not found in current directory or any parent directory; see 'go help modules'

是因为没有找到github上的包,直接用以下命令解决:

  1. $go mod init

屏幕会出现:

  1. go: creating new go.mod: module kingsoft
  2. go: to add module requirements and sums:
  3. go mod tidy

直接运行:

  1. go mod tidy

屏幕出现:

  1. go: finding module for package github.com/ks3sdklib/aws-sdk-go/aws/credentials
  2. go: finding module for package github.com/ks3sdklib/aws-sdk-go/service/s3
  3. go: finding module for package github.com/ks3sdklib/aws-sdk-go/aws
  4. go: found github.com/ks3sdklib/aws-sdk-go/aws in github.com/ks3sdklib/aws-sdk-go v1.0.11117
  5. go: found github.com/ks3sdklib/aws-sdk-go/aws/credentials in github.com/ks3sdklib/aws-sdk-go v1.0.11117
  6. go: found github.com/ks3sdklib/aws-sdk-go/service/s3 in github.com/ks3sdklib/aws-sdk-go v1.0.11117
  7. go: finding module for package github.com/stretchr/testify/assert
  8. go: finding module for package github.com/deckarep/golang-set
  9. go: finding module for package github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil
  10. go: downloading github.com/stretchr/testify v1.7.0
  11. go: downloading github.com/aws/aws-sdk-go v1.40.37
  12. go: downloading github.com/deckarep/golang-set v1.7.1
  13. go: found github.com/deckarep/golang-set in github.com/deckarep/golang-set v1.7.1
  14. go: found github.com/stretchr/testify/assert in github.com/stretchr/testify v1.7.0
  15. go: found github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil in github.com/aws/aws-sdk-go v1.40.37
  16. go: downloading github.com/davecgh/go-spew v1.1.0
  17. go: downloading gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
  18. go: downloading github.com/jmespath/go-jmespath v0.4.0

到此大功告成。

分类: web

标签:   golang