Package git provides an incomplete pure Go implementation of Git core methods.

git GoDoc

Package git provides an incomplete pure Go implementation of Git core methods.

Example

Code:

store := git.TempStore()
defer os.RemoveAll(string(store))

buf := new(bytes.Buffer)

// blob
bdata := []byte("hello, world")

bw := store.Writer()
bw.WriteHeader(git.Blob, len(bdata))
bw.Write(bdata)
bw.Close()

br, _ := store.Reader(bw.Hash())
io.Copy(buf, br)
br.Close()

buf.WriteRune('\n')

// tree
tdata := []byte(fmt.Sprintf("100644 blob %s\t%s\n", bw.Hash(), "hello.txt"))

tw := store.Writer()
tw.WriteHeader(git.Tree, -1)
tw.Write(tdata)
tw.Close()

tr, _ := store.Reader(tw.Hash(), git.PrettyReader)
io.Copy(buf, tr)
tr.Close()

fmt.Println(strings.Replace(buf.String(), "\t", " ", -1))

Output:

hello, world
100644 blob 8c01d89ae06311834ee4b1fab2f0414d35f01102 hello.txt

Caveats

  • Currently limited to loose objects
  • Reader and Writer for tree objects will likely fail on short reads and large content. Straight-forward to fix.
Owner
Daniel Skinner
despiteallobjections return
Daniel Skinner
Similar Resources

A highly extensible Git implementation in pure Go.

A highly extensible Git implementation in pure Go.

go-git is a highly extensible git implementation library written in pure Go. It can be used to manipulate git repositories at low level (plumbing) or

Jan 8, 2023

Golang 1.18+ Generics implementation of Set methods

Golang Generics: Set A golang 1.18+ implementation of Set using Go generics Installation $ go get -u github.com/chrispappas/golang-generics-set Quick

Oct 26, 2022

Package trn introduces a Range type with useful methods to perform complex operations over time ranges

Time Ranges Package trn introduces a Range type with useful methods to perform c

Aug 18, 2022

ReGit: A Tiny Git-Compatible Git Implementation written in Golang

ReGit is a tiny Git implementation written in Golang. It uses the same underlying file formats as Git. Therefore, all the changes made by ReGit can be checked by Git.

Oct 31, 2022

Examples using the stomp package from git://github.com/gmallard/stompngo.git

stompngo_examples - A collection of examples for package stompngo Features Full demonstration of support for STOMP protocols: Protocol Level 1.0 Proto

Jan 22, 2021

A Go implementation of the core algorithm in paper Indexing Boolean Expression

Boolean Expression Indexer Go library A Go implementation of the core algorithm in paper Indexing Boolean Expression, which already supports the fol

Dec 26, 2022

Reference implementation of the PLAN Data Model and core components

PLAN is a free and open platform for groups to securely communicate, collaborate, and coordinate projects and activities.

Nov 2, 2021

Parallel implementation of Gzip for modern multi-core machines written in Go

gzip Parallel implementation of gzip for modern multi-core machines written in Go Usage: gzip [OPTION]... [FILE] Compress or uncompress FILE (by defau

Nov 16, 2021

Package core is a service container that elegantly bootstrap and coordinate twelve-factor apps in Go.

Package core is a service container that elegantly bootstrap and coordinate twelve-factor apps in Go. Background The twelve-factor methodology has pro

Nov 3, 2022

parody of some of the basic python core features (collections package)

collections import "github.com/marcsantiago/collections" Overview Index Subdirectories Overview Index func StringEncoder(encoder *bytes.Buffer, data D

Jan 14, 2022

A command line http test tool. Maintain the case via git and pure text

A command line http test tool. Maintain the case via git and pure text

httptest A command line http test tool Maintain the api test cases via git and pure text We want to test the APIs via http requests and assert the res

Dec 16, 2022

Package ring provides a high performance and thread safe Go implementation of a bloom filter.

ring - high performance bloom filter Package ring provides a high performance and thread safe Go implementation of a bloom filter. Usage Please see th

Nov 20, 2022

Package notify provides an implementation of the Gnome DBus Notifications Specification.

go-notify Package notify provides an implementation of the Gnome DBus Notifications Specification. Examples Display a simple notification. ntf := noti

Dec 27, 2022

Ratelimit - This package provides a Golang implementation of the leaky-bucket rate limit algorithm

Go rate limiter This package provides a Golang implementation of the leaky-bucke

Jul 26, 2022

Wmi - One hot Go WMI package. Package wmi provides an interface to WMI. (Windows Management Instrumentation)

wmi Package wmi provides an interface to WMI. (Windows Management Instrumentation) Install go get -v github.com/moonchant12/wmi Import import "github.

Apr 22, 2022

Golang ultimate ANSI-colors that supports Printf/Sprintf methods

Golang ultimate ANSI-colors that supports Printf/Sprintf methods

Aurora Ultimate ANSI colors for Golang. The package supports Printf/Sprintf etc. TOC Installation Usage Simple Printf aurora.Sprintf Enable/Disable co

Dec 29, 2022

JSON or YAML configuration wrapper with convenient access methods.

Config Package config provides convenient access methods to configuration stored as JSON or YAML. This is a fork of the original version. This version

Dec 16, 2022

Probability distributions and associated methods in Go

godist godist provides some Go implementations of useful continuous and discrete probability distributions, as well as some handy methods for working

Sep 27, 2022
Installs git repos onto your system and keeps them up-to-date

Gitfile Installs git repos onto your system and keeps them up-to-date. It's a lightweight package manager for things that haven't been published to a

Jan 16, 2021
Tool to manage multiple git repositories

go-many-git Tool to manage multiple git repositories Requirements Proper go installation with GOPATH set git >= 1.8.5 Installation go get -u github.co

Aug 27, 2022
Git folder digger, I'm sure it's worthwhile stuff.
Git folder digger, I'm sure it's worthwhile stuff.

Gigger Git folder digger, I'm sure it's worthwhile stuff. Installation Download a prebuilt binary from releases page. or If you have recent go compile

Nov 9, 2022
Incomplete CRUD/RBAC service meant to be a practice for Go

Incomplete CRUD / RBAC Service in Go The repository name means nothing. But your task is to complete this repository on your own to be a functional CR

Nov 9, 2021
Gh-dungeon - An incomplete idea with golang
Gh-dungeon - An incomplete idea with golang

gh-dungeon an incomplete idea for a hack day, i wanted to experiment with "walki

Feb 3, 2022
Hanan - A terminal that brings out a form for inputs to a program (incomplete)

hanan a terminal that brings out a form for inputs to a program (incomplete) Dev

Nov 11, 2022
Package kml provides convenince methods for creating and writing KML documents.

go-kml Package kml provides convenience methods for creating and writing KML documents. Key Features Simple API for building arbitrarily complex KML d

Jul 29, 2022
Package iter provides generic, lazy iterators, functions for producing them from primitive types, as well as functions and methods for transforming and consuming them.

iter Package iter provides generic, lazy iterators, functions for producing them from primitive types, as well as functions and methods for transformi

Dec 16, 2022
A Go (golang) package that enhances the standard database/sql package by providing powerful data retrieval methods as well as DB-agnostic query building capabilities.

ozzo-dbx Summary Description Requirements Installation Supported Databases Getting Started Connecting to Database Executing Queries Binding Parameters

Dec 31, 2022
Go package providing opinionated tools and methods for working with the `aws-sdk-go/service/cloudfront` package.

go-aws-cloudfront Go package providing opinionated tools and methods for working with the aws-sdk-go/service/cloudfront package. Documentation Tools $

Feb 2, 2022