New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider keeping go-git as "pure Go" library #637
Comments
@radeksimko Thank you for raising this. TL;DR: I introduced the CGO dependency into go-git as a temporary step before For context, go-git previously did not support collision detection (which both Git CLI and libgit2 uses, as mentioned in the PR). The collision detection in itself is a lot less efficient than normal SHA1, given the additional state and operations it requires. The main reason why I ended up defaulting to the cgo version of For short and long terms, I am working on:
From my point of view, we should arrive there quite soon. |
Note: the git library we use now requires you to build with CGO_ENABLED=0. You as users of this library may have to add this to your builds! Sorry for this, please upvote go-git/go-git#637 if this annoys you.
latest go-git releases require gcc (CGO_ENABLED=1). We roll-back to older version to avoid this. See also: go-git/go-git#637
I think it would still be worth pursuing a pure Go solution, but FYI the recent Go 1.20 release contains a helpful change: https://tip.golang.org/doc/go1.20#cgo
It still doesn't quite help in the context of a library, as I initially described above, since we typically support last two stable releases, i.e. 1.19 + 1.20, so we'd at least have to wait for 1.21 to land, but it looks like a progress in the right direction. It may help any consumers with apps however, who can afford to just start building against 1.20. |
@radeksimko thanks for following up and yes, that would indeed be very helpful. On the PureGo front, I am almost done on getting sha1cd beating the CGO implementation's performance on AMD64. Once that is done we should be able to set it as the default. |
I stumbled across this issue, I can confirm upgrading to v5.5.1 resolves the issue. |
@mxplusb It resolves the issue for those who explicitly set For anyone else (on Go < 1.20 or not wanting to explicitly set |
this is broken, please fix. |
Hi folks,
Firstly - thank you for all the effort that goes into maintaining this library! ❤️
Over in https://github.com/hashicorp/hc-install we noticed that https://github.com/go-git/go-git/releases/tag/v5.5.0 introduced a CGO dependency https://github.com/pjbgf/sha1cd as part of #618 which made our Windows build fail.
hashicorp/hc-install#82
I appreciate that the library does have fallbacks (as introduced in 5.5.1), making it also work in non-CGO build environment. The (perhaps unfortunate?) reality is however, that Go has
CGO_ENABLED=1
defaults. This, in combination with us distributing a library (rather than an app) means that our own downstream is very likely to run into compilation issues on some platforms, as cross-compilation is generally difficult with CGO.We can of course just disable CGO and suggest downstream to do the same, but before taking that potentially painful step, I wanted to ask if you'd consider any resolution that would keep
go-git
as a pure Go library without any CGO dependency? It would help library consumers who wouldn't have to tweak the default options and wouldn't have to ask all of downstream to do the same.One of the main reasons we use
go-git
is to make minimal assumptions about the environment, but this recent change introduces an assumption, making the proposition far less interesting, to the point that I am considering abandoninggo-git
it foros/exec
and calling out togit
. It will introduce another type of headaches for end users who may not havegit
installed, but we trade it for the headache of downstream libraries having to setCGO_ENABLED=0
. 🤷🏻I will understand if the answer is no and respect it, but I wanted to share the context with the hope that you'll consider it.
The text was updated successfully, but these errors were encountered: