githash

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package githash provides a type for Git object hashes.

Index

Constants

View Source
const SHA1Size = 20

SHA1Size is the number of bytes in a SHA-1 hash.

Variables

This section is empty.

Functions

This section is empty.

Types

type SHA1

type SHA1 [SHA1Size]byte

A SHA1 is the SHA-1 hash of a Git object.

func ParseSHA1

func ParseSHA1(s string) (SHA1, error)

ParseSHA1 parses a hex-encoded SHA-1 hash. It is the same as calling UnmarshalText on a new SHA1.

func (SHA1) Format

func (h SHA1) Format(f fmt.State, c rune)

Format implements the fmt.Formatter interface. Specifically, it ensures that %x does not double-hex-encode the data.

func (SHA1) MarshalBinary

func (h SHA1) MarshalBinary() ([]byte, error)

MarshalBinary returns the hash as a byte slice.

func (SHA1) MarshalText

func (h SHA1) MarshalText() ([]byte, error)

MarshalText returns the hex-encoded hash.

func (SHA1) Short

func (h SHA1) Short() string

Short returns the first 4 hex-encoded bytes of the hash.

func (SHA1) String

func (h SHA1) String() string

String returns the hex-encoded hash.

func (*SHA1) UnmarshalBinary

func (h *SHA1) UnmarshalBinary(b []byte) error

UnmarshalBinary copies the bytes from b into h. It returns an error if len(b) != len(*h).

func (*SHA1) UnmarshalText

func (h *SHA1) UnmarshalText(s []byte) error

UnmarshalText decodes a hex-encoded hash into h.

Jump to

Keyboard shortcuts

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