DocHub icon indicating copy to clipboard operation
DocHub copied to clipboard

构建报错:type *api.PutObjectArgs has no field or method ContentEncoding

Open ChinaShrimp opened this issue 5 years ago • 2 comments

平台: OSX 10.15.2 GO: go1.12.5 darwin/amd64 代码分支: master

步骤:

  1. git clone代码到本地;
  2. 代码根目录创建go.mod文件,里面添加一行内容"module github.com/TruthHun/DocHub"
  3. 执行go build

报错信息如下:

$ go build go: finding golang.org/x/time/rate latest go: finding golang.org/x/time latest go: finding golang.org/x/sys/cpu latest go: finding golang.org/x/sys latest github.com/TruthHun/CloudStore ../../../go/pkg/mod/github.com/!truth!hun/[email protected]/bos.go:56:9: args.ContentEncoding undefined (type *api.PutObjectArgs has no field or method ContentEncoding)

分析: 前往CloudStore,发现bos.go中确实引用了ContentEncoding,但是百度最新的SDK中已经去除了这个域: case "content-encoding": args.ContentEncoding = v

临时修改方法:

  1. Fork CloudStore;
  2. 去除bos.go中这两行;
  3. 将DocHub中引用到github.com/TruthHun/CloudStore,改为自己Fork的库

经过验证,如上修改后可以正常编译,相关功能测试并未进行。

ChinaShrimp avatar Feb 03 '20 02:02 ChinaShrimp

一样的问题 issue

hawkwang avatar Feb 15 '20 16:02 hawkwang

我也遇到这个问题了,上面老哥说的有用 可以是fork项目 或者 直接复制CloudStore项目到你的DocHub工程也可以 去除bos.go两行 /* case "content-encoding": args.ContentEncoding = v */ 修改项目的引用为你自己的,具体就是 github.com/TruthHun/DocHub/helper 一些通用的工具类帮组类以外的业务相关代码都修改为你项目的包

jht385 avatar Feb 18 '20 08:02 jht385