Update the `README.md` to clarify some aspects of static libgit2 (#620)

This change improves the documentation surrounding libgit2 static builds
and modules.

Fixes: #618
This commit is contained in:
lhchavez 2020-06-20 16:24:46 -07:00 committed by GitHub
parent 1c9bef0f9f
commit 9eaf4fed5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -35,8 +35,8 @@ jobs:
run: |
git submodule update --init
make build-libgit2-static
go get --tags "static" github.com/${{ github.repository }}/...
go build --tags "static" github.com/${{ github.repository }}/...
go get -tags static github.com/${{ github.repository }}/...
go build -tags static github.com/${{ github.repository }}/...
- name: Test
env:
GOPATH: /home/runner/work/git2go

View File

@ -60,6 +60,16 @@ Run `go get -d github.com/libgit2/git2go` to download the code and go to your `$
will compile libgit2, link it into git2go and install it. The `master` branch is set up to follow the specific libgit2 version that is vendored, so trying dynamic linking may or may not work depending on the exact versions involved.
In order to let Go pass the correct flags to `pkg-config`, `-tags static` needs to be passed to all `go` commands that build any binaries. For instance:
go build -tags static github.com/my/project/...
go test -tags static github.com/my/project/...
go install -tags static github.com/my/project/...
One thing to take into account is that since Go expects the `pkg-config` file to be within the same directory where `make install-static` was called, so the `go.mod` file may need to have a [`replace` directive](https://github.com/golang/go/wiki/Modules#when-should-i-use-the-replace-directive) so that the correct setup is achieved. So if `git2go` is checked out at `$GOPATH/src/github.com/libgit2/git2go` and your project at `$GOPATH/src/github.com/my/project`, the `go.mod` file of `github.com/my/project` might need to have a line like
replace github.com/libgit2/git2go/v30 ../../libgit2/git2go
Parallelism and network operations
----------------------------------
@ -75,7 +85,7 @@ For the stable version, `go test` will work as usual. For the `master` branch, s
Alternatively, you can build the library manually first and then run the tests
./script/build-libgit2-static.sh
go test -v --tags "static" ./...
go test -v -tags static ./...
License
-------