【问题标题】:version of golang.org/x/sys@hash in go.mod ignoredgo.mod 中的 golang.org/x/sys@hash 版本被忽略
【发布时间】:2020-04-26 19:35:17
【问题描述】:

我正在尝试使用github.com/docker/engine 作为dockmoor 的依赖项,但是x/sys/windows 中有breaking changes,因此无法再为Windows 编译。

##[error]/home/runner/go/pkg/mod/github.com/docker/engine@v0.0.0-20200204220554-5f6d6f3f2203/pkg/system/filesys_windows.go:111:24:
cannot use uintptr(unsafe.Pointer(&sd[0])) (type uintptr) as type *"golang.org/x/sys/windows".SECURITY_DESCRIPTOR in assignment

我尝试使用例如设置golang.org/x/sys 的显式版本

go get -u golang.org/x/sys@acfa387b8d69adbeab4af0736737d42b9f2e8254

我可以看到我的go.mod中反映的版本,但是

GO111MODULE=on GOOS=windows go build ./cmd/dockmoor

导致同样的错误。

我还尝试了不同的修订,例如 14da1ac737ccc89e3a28bf770cbbd260ce7e190b 这是更改的父级,但我总是收到该错误。

golang.org/x/sys 的版本似乎被忽略了。

我最后一次尝试:
白鲸/引擎 v19.03.6 / v0.0.0-20200204220554-5f6d6f3f2203
Go 版本:1.12.16(与 moby/engine v19.03.6 中使用的相同)
golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed(与 moby/engine v19.03.6 中使用的相同)

知道如何解决这个问题吗?

【问题讨论】:

  • 你不能导入同一个包的多个版本,所以也许你有一个需要更新版本的依赖项?
  • 哦,我认为你是对的。我必须显式覆盖/x/sys,感谢指针,我错误地认为我显式声明的版本要么会被使用,要么会导致错误。

标签: go go-modules


【解决方案1】:

问题是一些依赖项拉入了另一个版本的golang.org/x/sys

解决方案是在go.mod 的末尾添加一个显式覆盖。就我而言,它看起来像这样

replace golang.org/x/sys => golang.org/x/sys v0.0.0-20190830141801-acfa387b8d69

【讨论】:

  • 我尝试这样做,但仍然收到 sam 错误。并在文件 filesys_windows.go 中突出显示第 112 行中的错误 sa.SecurityDescriptor = uintptr(unsafe.Pointer(&sd[0]))
猜你喜欢
  • 1970-01-01
  • 2020-10-15
  • 1970-01-01
  • 2018-07-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多