英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论