Categorygithub.com/magnuswahlstrand/gitfs
modulepackage
0.0.0-20240826084128-71ce912ab1f6
Repository: https://github.com/magnuswahlstrand/gitfs.git
Documentation: pkg.go.dev

# README

gitfs

A wrapper around go-git, compatible with the fs.FS and fs.StatFS from the standard library. package.

Usage

package main

import (
	"fmt"
	"github.com/magnuswahlstrand/gitfs"
	"io/fs"
	"log"
)

func main() {
	gitFS, err := gitfs.New("../local-repo")
	if err != nil {
		log.Fatalf("failed to setup repository: %s", err)
	}

	err = fs.WalkDir(gitFS, ".", func(path string, d fs.DirEntry, err error) error {
		if err != nil {
			log.Fatal(err)
		}
		fmt.Println(path)
		return nil
	})
	if err != nil {
		log.Fatalf("failed to walk dir: %s\n", err)
	}
}

Examples

See ./examples.

Basic (same as above)

go run ./examples/basic

Output:

.
.air.toml
.gitignore
LICENSE
README.md
examples
examples/basic
examples/basic/go.mod
examples/basic/go.sum
examples/basic/main.go
...

...
go.work
go.work.sum

Output markdown

Traverses a git repo and outputs the markdown in a nice way to the terminal.

go run ./examples/markdown-directory -repo https://github.com/magnuswahlstrand/til.git -path /src/pages/blog

Output:

img.png

# Functions

No description provided by the author

# Structs

FS wraps a git work tree.