Reputation: 747
My compiled Go code does not end with an extension on Linux.
Any tips for handling ignoring these in the .gitignore file?
Upvotes: 13
Views: 5837
Reputation: 9228
Just Ignore all files in the required directory except go files.
E.g assume your main.go
and binary file with name main are in the same directory i.e main/main.go
and main/main
Modify your .gitignore
to ignore all files inside the main directory except files with the .go
extension
main/*
!main/*.go
Upvotes: 0
Reputation:
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.
Upvotes: 16
Reputation: 54163
Keep your build products separate from your source code. This has several advantages:
rm -rf objdir
will remove files that a buggy make clean
will missgit clean -dxf
will clean your source tree, but won't touch your built filesNote that GNU Automake and Make support a feature called VPATH to make it easy to separate the source tree from the build tree.
Upvotes: 9
Reputation: 9932
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
.
Upvotes: 3
Reputation: 15829
Just add the names of the files in your .gitignore
? Tedious, but it will work.
Upvotes: 3