构建报错:type *api.PutObjectArgs has no field or method ContentEncoding
平台: OSX 10.15.2 GO: go1.12.5 darwin/amd64 代码分支: master
步骤:
- git clone代码到本地;
- 代码根目录创建go.mod文件,里面添加一行内容"module github.com/TruthHun/DocHub"
- 执行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
临时修改方法:
- Fork CloudStore;
- 去除bos.go中这两行;
- 将DocHub中引用到github.com/TruthHun/CloudStore,改为自己Fork的库
经过验证,如上修改后可以正常编译,相关功能测试并未进行。
一样的问题
我也遇到这个问题了,上面老哥说的有用
可以是fork项目 或者 直接复制CloudStore项目到你的DocHub工程也可以
去除bos.go两行
/* case "content-encoding": args.ContentEncoding = v */
修改项目的引用为你自己的,具体就是 github.com/TruthHun/DocHub/helper 一些通用的工具类帮组类以外的业务相关代码都修改为你项目的包