gitfs

package module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2022 License: MIT Imports: 10 Imported by: 1

README

gitfs

doc

Read a remote git repository as io/fs.FS.

Example

func main() {
	// init file system
	fsys, _ := gitfs.New("https://github.com/boltdb/bolt")

	// read root directory
	data, _ := fs.ReadFile(fsys, "README.md")

	// print files
	fmt.Println(string(data)[:4])
	// Output: Bolt
}

Documentation

Overview

Example
package main

import (
	"fmt"
	"io/fs"

	"github.com/forensicanalysis/gitfs"
)

func main() {
	// init file system
	fsys, _ := gitfs.New("https://github.com/boltdb/bolt")

	// read root directory
	data, _ := fs.ReadFile(fsys, "README.md")

	// print files
	fmt.Println(string(data)[:4])
}
Output:

Bolt

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GitEntry

type GitEntry struct {
	// contains filtered or unexported fields
}

func (*GitEntry) Info

func (g *GitEntry) Info() (fs.FileInfo, error)

func (*GitEntry) IsDir

func (g *GitEntry) IsDir() bool

func (*GitEntry) ModTime

func (g *GitEntry) ModTime() time.Time

func (*GitEntry) Mode

func (g *GitEntry) Mode() fs.FileMode

func (*GitEntry) Name

func (g *GitEntry) Name() string

func (*GitEntry) Size

func (g *GitEntry) Size() int64

func (*GitEntry) Sys

func (g *GitEntry) Sys() interface{}

func (*GitEntry) Type

func (g *GitEntry) Type() fs.FileMode

type GitFS

type GitFS struct {
	FS billy.Filesystem
}

func New

func New(url string) (*GitFS, error)

func NewWithOptions added in v0.2.0

func NewWithOptions(options *git.CloneOptions) (*GitFS, error)

func (*GitFS) Open

func (g *GitFS) Open(name string) (fs.File, error)

func (*GitFS) ReadDir

func (g *GitFS) ReadDir(name string) (entries []fs.DirEntry, err error)

func (*GitFS) Stat

func (g *GitFS) Stat(name string) (fs.FileInfo, error)

type GitFile

type GitFile struct {
	// contains filtered or unexported fields
}

func (*GitFile) Close

func (g *GitFile) Close() error

func (*GitFile) Read

func (g *GitFile) Read(bytes []byte) (int, error)

func (*GitFile) ReadDir

func (g *GitFile) ReadDir(n int) ([]fs.DirEntry, error)

func (*GitFile) Stat

func (g *GitFile) Stat() (fs.FileInfo, error)

type PseudoDir

type PseudoDir struct {
	// contains filtered or unexported fields
}

func (*PseudoDir) Close

func (p *PseudoDir) Close() error

func (*PseudoDir) Read

func (p *PseudoDir) Read([]byte) (int, error)

func (*PseudoDir) ReadDir

func (p *PseudoDir) ReadDir(n int) ([]fs.DirEntry, error)

func (*PseudoDir) Stat

func (p *PseudoDir) Stat() (fs.FileInfo, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL