Skip to content

Commit 9eaf4fe

Browse files
authored
Update the README.md to clarify some aspects of static libgit2 (libgit2#620)
This change improves the documentation surrounding libgit2 static builds and modules. Fixes: libgit2#618
1 parent 1c9bef0 commit 9eaf4fe

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ jobs:
3535
run: |
3636
git submodule update --init
3737
make build-libgit2-static
38-
go get --tags "static" github.com/${{ github.repository }}/...
39-
go build --tags "static" github.com/${{ github.repository }}/...
38+
go get -tags static github.com/${{ github.repository }}/...
39+
go build -tags static github.com/${{ github.repository }}/...
4040
- name: Test
4141
env:
4242
GOPATH: /home/runner/work/git2go

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ Run `go get -d github.com/libgit2/git2go` to download the code and go to your `$
6060

6161
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.
6262

63+
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:
64+
65+
go build -tags static github.com/my/project/...
66+
go test -tags static github.com/my/project/...
67+
go install -tags static github.com/my/project/...
68+
69+
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
70+
71+
replace github.com/libgit2/git2go/v30 ../../libgit2/git2go
72+
6373
Parallelism and network operations
6474
----------------------------------
6575

@@ -75,7 +85,7 @@ For the stable version, `go test` will work as usual. For the `master` branch, s
7585
Alternatively, you can build the library manually first and then run the tests
7686

7787
./script/build-libgit2-static.sh
78-
go test -v --tags "static" ./...
88+
go test -v -tags static ./...
7989

8090
License
8191
-------

0 commit comments

Comments
 (0)