Generate stringer files automatically #841
Loading…
Reference in New Issue
No description provided.
Delete Branch "543-stringer-generate"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Added
stringer
annotations togit.go
forErrorClass
andErrorCode
. Addedgenerate
rule forMakefile
to generatestring representations for these types (first building cgo files
in
_obj
dir to get C constants). Finally, updatedci
actionsworkflow to check that generated files are up to date.
Fixes: #543
yay, thanks for the CI addition!
this way the caller will be able to see what were the changes.
is it possible to have this be
? that way whenever a new stringer is added, the Makefile doesn't need to be updated (folks will forget about this, haha). the
_gen_file
function also depends a bit on implementation details that are not guaranteed to be true forever.Unfortunately,
go generate --tags "static" ./...
will not work with CGO constants from libgit2 headers (as indiff.go
andgit.go
), so it's a workaround to extract these constants from header files to.go
files, see this question: https://stackoverflow.com/q/69566767/1723695@lhchavez thanks for review! Please check new changes and answers.
@ -108,0 +122,4 @@
git submodule update --init
sudo apt-get install -y --no-install-recommends libssh2-1-dev
go install golang.org/x/tools/cmd/stringer@latest
- name: Generate files
oops, forgot this last round! otherwise
make generate
will fail because CGo won't be able to findgit2.h
: https://github.com/libgit2/git2go/runs/4139740720?check_suite_focus=true (note that this depends on the suggestion that was left inMakefile
to work correctly).oh that's likely because the static library wasn't correctly built / installed (that's why the
generate:
rule hasstatic-build/install/lib/libgit2.a
as a dependency, which fixes this issue). i just tried this on my machine and it worked. can you give this a try?also, minor thing, can the
generate
rule be moved to just below thedefault:
one? i just realized that it's included in the various library sections, and that was a bit confusing, haha.Thanks, it's working now, updated in the latest commit
@ -108,0 +120,4 @@
- name: Install libgit2 build dependencies
run: |
git submodule update --init
sudo apt-get install -y --no-install-recommends libssh2-1-dev
haha,
stringer
wasn't installed! (and we may need to tweakPATH
unless GH does it for us)Exported
GOPATH
in9c737a6d50
yay! now it works in CI!
thank you for this improvement :D