checksum

package module
v0.0.0-...-d08dd98 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2017 License: GPL-2.0 Imports: 8 Imported by: 0

README

Checksum GoDoc

An easy way to get checksums of files and compare them.

Documentation

Overview

Package checksum gets the checksum of a file or files withing a directory.

You will need to import the appropriate package in you package to be able to get the checksum of the files. Check out https://golang.org/pkg/crypto/#Hash to get a list of possable checksums and which imports to include in your package. You will need to do something like:

import _ "crypto/md5"

to import the appropriate hash into your package.

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrCannotBeRead is returned when file or folder could not be read for meta information.
	ErrCannotBeRead = errors.New("This file/folder could not be read")
	//ErrFileReading is returned when while reading the file an error occured.
	ErrFileReading = errors.New("This file had an error while reading")
	//ErrFileNotOpen is returned when this package could not open the file for reading.
	ErrFileNotOpen = errors.New("This file could not be opened")
	//ErrFileIsDirectory is returned when using the wrong method when passing in a directory.
	ErrFileIsDirectory = errors.New("File is a directory and should use the Directory function")
	//ErrHashBinary is returned when the proper binary is not included in the executable for the given has.
	ErrHashBinary = errors.New("Supplied hash's binary is not included in executable")
	//ErrImproperLength is returned when the expected number of bytes is not written to the hashing function.
	ErrImproperLength = errors.New("Did not write expected number of bytes to the hashing function")
	//ErrWritingHash is returned when there was a problem writing bytes to the hashing function.
	ErrWritingHash = errors.New("Could not write bytes to the hashubg function")
	//ErrWalking is returned when there was an issue walking to the specified file or folder.
	ErrWalking = errors.New("There was a problem walking to this file/folder")
	//ErrNotRegular is returned when the file is not a regular file.
	ErrNotRegular = errors.New("The file is not a regular file")
)
View Source
var (
	//BufferSize is used to buffer the file before hashing.
	BufferSize = 4096
	//Limit is the limit of how many open files to process at one time.
	Limit = 100
)

Functions

func Directory

func Directory(root string, h crypto.Hash, response chan FileChecksumResponse)

Directory gets the checksum of all files in the directory and responds on the channel.

func File

func File(path string, h crypto.Hash, response chan FileChecksumResponse)

File gets the checksum of the file and responds on the channel passed in.

Types

type CSError

type CSError struct {
	Path  string
	Err   error
	Inner error
}

CSError is any checksum Error.

func NewError

func NewError(path string, err, inner error) CSError

NewError creates a new CSError.

func (CSError) Error

func (e CSError) Error() string

Error is used to implement the Error interface.

type FileChecksum

type FileChecksum struct {
	FilePath string
	Checksum []byte
}

FileChecksum is the checksum of a file.

type FileChecksumResponse

type FileChecksumResponse struct {
	Checksum *FileChecksum
	Err      error
}

FileChecksumResponse is a response from this library over the channel.

func NewResponse

func NewResponse(checksum *FileChecksum, err error) FileChecksumResponse

NewResponse creates a new response for the channel.

Directories

Path Synopsis
cmd
checksum
checksum creates a cli function for creating checksums of files Install To install my application run: go get github.com/dixonwille/checksum/cmd/checksum or go to the release on github and grab the appropriate binary.
checksum creates a cli function for creating checksums of files Install To install my application run: go get github.com/dixonwille/checksum/cmd/checksum or go to the release on github and grab the appropriate binary.

Jump to

Keyboard shortcuts

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