Git: Ignore compiled Google Go

拟墨画扇 提交于 2019-12-09 17:56:00

问题


My compiled Go code does not end with an extension on Linux.

Any tips for handling ignoring these in the .gitignore file?


回答1:


Keep your build products separate from your source code. This has several advantages:

  • you can start many different builds of the same code at the same time without creating multiple clones
  • it's easy to be confident that you've really done a clean; rm -rf objdir will remove files that a buggy make clean will miss
  • you can kick off a build from a read-only copy of the source tree (e.g., CD-ROM)
  • you're less likely to accidentally commit generated files
  • git clean -dxf will clean your source tree, but won't touch your built files

Note that GNU Automake and Make support a feature called VPATH to make it easy to separate the source tree from the build tree.




回答2:


If you are using the go tool to build your code you can use the -o flag to specify the output file name, so you can for example use go build -o bin/elf and then add bin/* to your .gitignore file.




回答3:


Just add the names of the files in your .gitignore? Tedious, but it will work.




回答4:


The .gitignore language isn't Turing complete. It can only match fairly simple patterns. This just means you need something else that can figure out what possible executables should be excluded. So, write a script that creates .gitignore based on the names of the executables that can be created. If you want to be fancy, make an alias that runs it before git add.



来源:https://stackoverflow.com/questions/9952061/git-ignore-compiled-google-go

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!