Documentation ¶
Overview ¶
Example (Gitoid_bytes_sha1) ¶
package main import ( "bytes" "fmt" "github.com/edwarnicke/gitoid" ) func main() { input := []byte("example") gitoidHash, _ := gitoid.New(bytes.NewBuffer(input)) fmt.Println(gitoidHash) }
Output: 96236f8158b12701d5e75c14fb876c4a0f31b963
Example (Gitoid_sha1) ¶
package main import ( "fmt" "os" "github.com/edwarnicke/gitoid" ) const filename = "LICENSE" func main() { file, _ := os.Open(filename) defer file.Close() gitoidHash, _ := gitoid.New(file) fmt.Println(gitoidHash) }
Output: 261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64
Example (Gitoid_sha1_content_length) ¶
package main import ( "fmt" "os" "github.com/edwarnicke/gitoid" ) const filename = "LICENSE" func main() { file, _ := os.Open(filename) defer file.Close() fi, _ := file.Stat() gitoidHash, _ := gitoid.New(file, gitoid.WithContentLength(fi.Size())) fmt.Println(gitoidHash) }
Output: 261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64
Example (Gitoid_sha256) ¶
package main import ( "fmt" "os" "github.com/edwarnicke/gitoid" ) const filename = "LICENSE" func main() { file, _ := os.Open(filename) defer file.Close() gitoidHash, _ := gitoid.New(file, gitoid.WithSha256()) fmt.Println(gitoidHash) }
Output: ed43975fbdc3084195eb94723b5f6df44eeeed1cdda7db0c7121edf5d84569ab
Example (Gitoid_uri_sha1) ¶
package main import ( "fmt" "os" "github.com/edwarnicke/gitoid" ) const filename = "LICENSE" func main() { file, _ := os.Open(filename) defer file.Close() gitoidHash, _ := gitoid.New(file) fmt.Println(gitoidHash.URI()) }
Output: gitoid:blob:sha1:261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64
Example (Gitoid_uri_sha256) ¶
package main import ( "fmt" "os" "github.com/edwarnicke/gitoid" ) const filename = "LICENSE" func main() { file, _ := os.Open(filename) defer file.Close() gitoidHash, _ := gitoid.New(file, gitoid.WithSha256()) fmt.Println(gitoidHash.URI()) }
Output: gitoid:blob:sha256:ed43975fbdc3084195eb94723b5f6df44eeeed1cdda7db0c7121edf5d84569ab
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidGitOIDURI = errors.New("invalid uri in gitoid.FromURI")
var ErrMayNotBeNil = errors.New("may not be nil")
Functions ¶
func Header ¶
func Header(gitObjectType GitObjectType, contentLength int64) []byte
Header - returns the git object header from the gitObjectType and contentLength.
Types ¶
type GitOID ¶
type GitOID struct {
// contains filtered or unexported fields
}
func FromURI ¶
FromURI - returns a *GitOID from a gitoid uri string - see https://www.iana.org/assignments/uri-schemes/prov/gitoid
func (*GitOID) URI ¶
URI - returns the gitoid as a URI (https://www.iana.org/assignments/uri-schemes/prov/gitoid)
type GitObjectType ¶
type GitObjectType string
GitObjectType type of git object - current values are "blob", "commit", "tag", "tree".
const ( BLOB GitObjectType = "blob" COMMIT GitObjectType = "commit" TAG GitObjectType = "tag" TREE GitObjectType = "tree" )
type Option ¶
type Option func(o *option)
Option - option for GitOID creation.
func WithContentLength ¶
WithContentLength - allows the assertion of a contentLength to be read from the provided reader
only the first contentLength of data will be read from the reader if contentLength bytes are unavailable from the reader, an error will be returned.
func WithGitObjectType ¶
func WithGitObjectType(gitObjectType GitObjectType) Option
WithGitObjectType - set the GitOobjectType to a value different than the default gitoid.BLOB type.
func WithSha256 ¶
func WithSha256() Option
WithSha256 - use sha256 for computing gitoids instead of the default sha1.