Skip to content

nandeshguru/s3git-go

 
 

Repository files navigation

s3git-go

Join the chat at https://gitter.im/s3git/s3git

This is the go SDK package for s3git.

For brevity reasons, error handling and other boilerplate code like package naming etc. is not shown in the examples. Actual client code should always check for errors, see s3git as an example.

DISCLAIMER: This software is still under development (although the storage format/model using BLAKE2 hashing is stable) -- use at your own peril for now

Note that the API is not stable yet, you can expect minor changes

BLAKE2 Tree Hashing

If you would like to understand how s3git uses the BLAKE2 Tree hashing mode please see here.

Development environment

See here for setting up the development environment.

Create a repository

import "github.com/s3git/s3git-go"

// Create repo
repo, _ := s3git.InitRepository(".")

// Add some data
repo.Add(strings.NewReader("hello s3git"))

// Commit changes
repo.Commit("Initial commit")

// List commits
commits, _ := repo.ListCommits("")

for commit := range commits {
    fmt.Println(commit)
}

See here for the full example (and others). And run like this:

$ cd $GOPATH/src/github.com/s3git/s3git-go/examples
$ go run create.go

Clone a repository

import "github.com/s3git/s3git-go"

options := []s3git.CloneOptions{}
options = append(options, s3git.CloneOptionSetAccessKey("AKIAJYNT4FCBFWDQPERQ"))
options = append(options, s3git.CloneOptionSetSecretKey("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"))

// Clone a repo
repo, _ := s3git.Clone("s3://s3git-spoon-knife", ".", options...)

// List contents
list, _ := repo.List("")

for l := range list {
    fmt.Println(l)
}

Make changes and push

import "github.com/s3git/s3git-go"

repo, _ := s3git.OpenRepository(".")

repo.Add(strings.NewReader(fmt.Sprint(time.Now())))

repo.Commit("New commit")

hydrate := false 	// For explanation, see https://github.com/s3git/s3git/blob/master/BLAKE2.md#hydrated
repo.Push(hydrate)

See change_and_push.go.

Pull down changes

import "github.com/s3git/s3git-go"

repo, _ := s3git.OpenRepository(".")

repo.Pull()

repo.Log()

Extract data

import "github.com/s3git/s3git-go"

repo, _ := s3git.OpenRepository(".")

r, _ := repo.Get("012345678")

io.Copy(os.Stdout, r)

Clone a repository with progress

import "github.com/s3git/s3git-go"

repo, _ := s3git.Clone("s3://s3git-100m", ".")

Contributions

Contributions are welcome! Please see CONTRIBUTING.md.

License

s3git-go is released under the Apache License v2.0. You can find the complete text in the file LICENSE.

About

SDK package in Golang for s3git: git for Cloud Storage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%