NIX – go: 模块已被 GO111MODULE=off 禁用;

huangapple go评论200阅读模式
英文:

NIX - go: modules disabled by GO111MODULE=off;

问题

我正在尝试使用nix下载和构建一个用golang编写的项目。

我的nix文件:

buildGoPackage {
  name = "site";
  goPackagePath = "git@github.com:username/rep.git";
  src = fetchGit{
       url = "git@github.com:username/rep.git";
  };
}

运行:

nix build -f test3.nix

错误日志:

last 8 log lines:
 > unpacking sources
 > unpacking source archive /nix/store/l1gsllgg693s46sk7b7qiwbnjysnbbz6-source
 > source root is source
 > patching sources
 > configuring
 > building
 > Building subPackage git@github.com:user/rep.git
 > go: modules disabled by GO111MODULE=off; see 'go help modules'
英文:

I'm trying to download and build a project written in golang using nix

My nix file:

buildGoPackage {      
  name = "site";     
  goPackagePath = "git@github.com:username/rep.git";    
  src = fetchGit{      
       url = "git@github.com:username/rep.git";     
  }; 
}

run:

nix build -f test3.nix

error log:

last 8 log lines:        
 > unpacking sources       
 > unpacking source archive /nix/store/l1gsllgg693s46sk7b7qiwbnjysnbbz6-source        
 > source root is source        
 > patching sources        
 > configuring       
 > building        
 > Building subPackage git@github.com:user/rep.git        
 > go: modules disabled by GO111MODULE=off; see 'go help modules'

答案1

得分: 1

我认为你应该使用buildGoModule而不是buildGoPackage,因为根据go的nixpkgs文档buildGoPackage已经被弃用。

此外,buildGoModule似乎没有设置GO111MODULE=off

英文:

I think you should be using buildGoModule instead of buildGoPackage, as buildGoPackage is deprecated, according to the nixpkgs documentation for go.

Additionally, buildGoModule doesn't seem to set GO111MODULE=off.

huangapple
  • 本文由 发表于 2023年2月2日 18:32:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/75321827.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定