mirror of https://github.com/minio/minio.git
Add strict checks with vet, golint and gofmt
This commit is contained in:
parent
d02fb75dfd
commit
b952855779
19
Makefile
19
Makefile
|
@ -12,12 +12,23 @@ checkgopath:
|
||||||
|
|
||||||
getdeps: checkdeps checkgopath
|
getdeps: checkdeps checkgopath
|
||||||
@go get github.com/tools/godep && echo "Installed godep"
|
@go get github.com/tools/godep && echo "Installed godep"
|
||||||
|
@go get github.com/golang/lint/golint && echo "Installed golint"
|
||||||
|
@go get golang.org/x/tools/cmd/vet && echo "Installed vet"
|
||||||
|
|
||||||
verifier: getdeps
|
verifiers: getdeps vet fmt lint
|
||||||
@echo "Checking for offending code"
|
|
||||||
@go run buildscripts/verifier.go ${PWD}
|
|
||||||
|
|
||||||
build-all: verifier
|
vet:
|
||||||
|
@echo "Running $@"
|
||||||
|
@go vet ./...
|
||||||
|
fmt:
|
||||||
|
@echo "Running $@"
|
||||||
|
@test -z "$$(gofmt -s -l . | grep -v Godeps/_workspace/src/ | tee /dev/stderr)" || \
|
||||||
|
echo "+ please format Go code with 'gofmt -s'"
|
||||||
|
lint:
|
||||||
|
@echo "Running $@"
|
||||||
|
@test -z "$$(golint ./... | grep -v Godeps/_workspace/src/ | tee /dev/stderr)"
|
||||||
|
|
||||||
|
build-all: verifiers
|
||||||
@echo "Building Libraries"
|
@echo "Building Libraries"
|
||||||
@godep go generate ./...
|
@godep go generate ./...
|
||||||
@godep go build ./...
|
@godep go build ./...
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
package crc32c
|
package crc32c
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
|
||||||
"hash/crc32"
|
"hash/crc32"
|
||||||
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
var castanagoliTable = crc32.MakeTable(crc32.Castagnoli)
|
var castanagoliTable = crc32.MakeTable(crc32.Castagnoli)
|
||||||
|
|
|
@ -100,10 +100,10 @@ func (d *digest) Write(p []byte) (nn int, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return checksum bytes
|
// Return checksum bytes
|
||||||
func (d0 *digest) Sum(in []byte) []byte {
|
func (d *digest) Sum(in []byte) []byte {
|
||||||
// Make a copy of d0 so that caller can keep writing and summing.
|
// Make a copy of d0 so that caller can keep writing and summing.
|
||||||
d := *d0
|
d0 := *d
|
||||||
hash := d.checkSum()
|
hash := d0.checkSum()
|
||||||
return append(in, hash[:]...)
|
return append(in, hash[:]...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,5 +17,3 @@ func blockAVX2(dig *digest, p []byte) {
|
||||||
func blockSSE3(dig *digest, p []byte) {
|
func blockSSE3(dig *digest, p []byte) {
|
||||||
C.sha1_update_intel((*C.int32_t)(unsafe.Pointer(&dig.h[0])), (*C.char)(unsafe.Pointer(&p[0])), (C.size_t)(len(p)/chunk))
|
C.sha1_update_intel((*C.int32_t)(unsafe.Pointer(&dig.h[0])), (*C.char)(unsafe.Pointer(&p[0])), (C.size_t)(len(p)/chunk))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -106,10 +106,10 @@ func (d *digest) Write(p []byte) (nn int, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return sha256 sum in bytes
|
// Return sha256 sum in bytes
|
||||||
func (d0 *digest) Sum(in []byte) []byte {
|
func (d *digest) Sum(in []byte) []byte {
|
||||||
// Make a copy of d0 so that caller can keep writing and summing.
|
// Make a copy of d0 so that caller can keep writing and summing.
|
||||||
d := *d0
|
d0 := *d
|
||||||
hash := d.checkSum()
|
hash := d0.checkSum()
|
||||||
return append(in, hash[:]...)
|
return append(in, hash[:]...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,11 +107,10 @@ func (d *digest) Write(p []byte) (nn int, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate sha512
|
// Calculate sha512
|
||||||
func (d0 *digest) Sum(in []byte) []byte {
|
func (d *digest) Sum(in []byte) []byte {
|
||||||
// Make a copy of d0 so that caller can keep writing and summing.
|
// Make a copy of d0 so that caller can keep writing and summing.
|
||||||
d := new(digest)
|
d0 := *d
|
||||||
*d = *d0
|
hash := d0.checkSum()
|
||||||
hash := d.checkSum()
|
|
||||||
return append(in, hash[:]...)
|
return append(in, hash[:]...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue