A simple to use go fs.FS based github filesystem.
org_or_user/ // org or username
└── repository // repository
├── git // fixed name 'git'
│ └── main // the branch name
│ └── README.md // the files in the repo
└── releases // fixed name 'releases'
└── v0.0.1 // release version
└── description.md // the description of the release and other files from the release
package githubfs import ( "context" "fmt" "io/fs" "os" "github.com/schmidtw/githubfs" "golang.org/x/oauth2" ) func main() { src := oauth2.StaticTokenSource( &oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")}, ) httpClient := oauth2.NewClient(context.Background(), src) gfs := githubfs.New( githubfs.WithHttpClient(httpClient), githubfs.WithRepo("schmidtw", "githubfs"), ) err := fs.WalkDir(gfs, "schmidtw/githubfs/git/main/.reuse", func(path string, d fs.DirEntry, err error) error { fmt.Printf("%s\n", path) if err != nil || d.IsDir() { return err } return nil }) if err != nil { panic(err) } }
- Symlinks are only supported for files fetched for small repos (where the fetch occurs via a tarball).
- Packages are not supported by the github graphql API, so they aren't supported here.
- Gists are not supported presently.