Any git repository with C source files can be a goose package. Adding a goose.yaml gives consumers the best experience.
Recommended layout:
mylib/
goose.yaml
include/ <- public headers (consumers include from here)
mylib.h
src/ <- implementation files
mylib.c
internal.h <- private headers
tests/ <- optional tests
test_mylib.c
.gitignore
project:
name: "mylib"
version: "1.0.0"
description: "What this library does"
author: "Your Name"
license: "MIT"
build:
cc: "cc"
cflags: "-Wall -Wextra -std=c11"
includes:
- "include"
dependencies:The includes list is critical for libraries. It tells consumers which directories contain your public headers. Only paths listed here become -I flags in the consumer's build.
A common pattern:
include/- Public API headers that consumers usesrc/- Implementation files and private headers
In your goose.yaml, only list include/ in includes. Your own .c files can use relative includes for private headers:
// src/mylib.c
#include <mylib.h> // public header (via -Iinclude)
#include "internal.h" // private header (relative to src/)If your .c files need to include from include/ too, add both:
build:
includes:
- "include"
- "src"Currently, goose uses git URLs directly. To make your package available:
- Push your repository to GitHub (or any git host)
- Tag releases:
git tag v1.0.0 && git push --tags - Share the URL:
goose add https://github.com/you/mylib.git
Users can pin to a tag:
goose add https://github.com/you/mylib.git --version v1.0.0Libraries can have their own dependencies in goose.yaml. When a consumer adds your library, goose fetches transitive dependencies automatically.
Add tests in a tests/ directory:
// tests/test_mylib.c
#include <assert.h>
#include <mylib.h>
int main(void) {
// test your library
assert(my_function() == expected);
return 0; // 0 = pass
}Run with goose test.
See the examples/ directory in the goose repository:
examples/mathlib/- A math utility library withinclude/andsrc/separationexamples/stringlib/- A string utility libraryexamples/mathapp/- An application consuming both libraries