lint: fix issues in examples (#49)
This commit is contained in:
@@ -21,3 +21,5 @@ issues:
|
||||
exclude:
|
||||
# errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
|
||||
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked
|
||||
# gocritic: unlambda with builtins is invalid.
|
||||
- ' with `(len|cap|real|imag)`'
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package args
|
||||
|
||||
// Struct is a struct containing various datatypes, to help demonstrate struct field access.
|
||||
type Struct struct {
|
||||
Byte byte
|
||||
Int8 int8
|
||||
@@ -15,6 +16,7 @@ type Struct struct {
|
||||
Complex128 complex128
|
||||
}
|
||||
|
||||
// Sub is a sub-struct of Struct, to demonstrate nested datastructure accesses.
|
||||
type Sub struct {
|
||||
A uint64
|
||||
B [3]byte
|
||||
|
||||
@@ -11,7 +11,9 @@ import (
|
||||
func TestHash64(t *testing.T) {
|
||||
expect := func(data []byte) uint64 {
|
||||
h := fnv.New64a()
|
||||
h.Write(data)
|
||||
if _, err := h.Write(data); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return h.Sum64()
|
||||
}
|
||||
if err := quick.CheckEqual(Hash64, expect, nil); err != nil {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package returns
|
||||
|
||||
// Struct is used to deomonstrate writing struct return values.
|
||||
type Struct struct {
|
||||
Word uint16
|
||||
Point [2]float64
|
||||
|
||||
@@ -4,11 +4,13 @@ import (
|
||||
"encoding/binary"
|
||||
)
|
||||
|
||||
const (
|
||||
Size = 20
|
||||
BlockSize = 64
|
||||
)
|
||||
// Size of a SHA-1 checksum in bytes.
|
||||
const Size = 20
|
||||
|
||||
// BlockSize is the block size of SHA-1 in bytes.
|
||||
const BlockSize = 64
|
||||
|
||||
// Sum returns the SHA-1 checksum of data.
|
||||
func Sum(data []byte) [Size]byte {
|
||||
n := len(data)
|
||||
h := [5]uint32{0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0}
|
||||
@@ -21,7 +23,7 @@ func Sum(data []byte) [Size]byte {
|
||||
|
||||
// Final block.
|
||||
tmp := make([]byte, BlockSize)
|
||||
copy(tmp[:], data)
|
||||
copy(tmp, data)
|
||||
tmp[len(data)] = 0x80
|
||||
|
||||
if len(data) >= 56 {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Downloaded from https://raw.githubusercontent.com/demerphq/BeagleHash/5f8620b953230e5b16171b745155fc3b0ef8f75e/LICENSE
|
||||
// Code generated by downloading from https://raw.githubusercontent.com/demerphq/BeagleHash/5f8620b953230e5b16171b745155fc3b0ef8f75e/LICENSE. DO NOT EDIT.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
@@ -4,7 +4,7 @@ dl() {
|
||||
url=$1
|
||||
filename=$(basename $1)
|
||||
{
|
||||
echo "// Downloaded from ${url}"
|
||||
echo "// Code generated by downloading from ${url}. DO NOT EDIT."
|
||||
echo
|
||||
curl -L ${url}
|
||||
} > ${filename}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Downloaded from https://github.com/dgryski/go-stadtx/raw/3c3d9b328c24a9b5ecd370654cd6e9d60a85752d/stadtx.go
|
||||
// Code generated by downloading from https://github.com/dgryski/go-stadtx/raw/3c3d9b328c24a9b5ecd370654cd6e9d60a85752d/stadtx.go. DO NOT EDIT.
|
||||
|
||||
// Package stadtx implements Stadtx Hash
|
||||
/*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Downloaded from https://github.com/dgryski/go-stadtx/raw/3c3d9b328c24a9b5ecd370654cd6e9d60a85752d/stadtx_test.go
|
||||
// Code generated by downloading from https://github.com/dgryski/go-stadtx/raw/3c3d9b328c24a9b5ecd370654cd6e9d60a85752d/stadtx_test.go. DO NOT EDIT.
|
||||
|
||||
package stadtx
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ post=$(go list ./... | grep -E 'avo/(examples|tests)')
|
||||
go install ./internal/cmd/avogen
|
||||
|
||||
# Attempt to delete generated files, to prove we can recreate them.
|
||||
grep -REl 'Code generated.*DO NOT EDIT\.$' . | grep -v '.md$' | xargs rm -v
|
||||
grep -RE '^// Code generated.*DO NOT EDIT\.$' . | grep -v download | cut -d: -f1 | grep -v '.md$' | xargs rm -v
|
||||
|
||||
# Generate once.
|
||||
go generate -v -x ${core}
|
||||
|
||||
@@ -10,4 +10,5 @@ find . -name '*.s' | xargs asmfmt -w
|
||||
test -z "$(git status --porcelain)"
|
||||
|
||||
# Run suite of golangci-lint checks.
|
||||
golangci-lint run
|
||||
# (Provide examples directory explicitly since it is skipped by default.)
|
||||
golangci-lint run ./... ./examples/...
|
||||
|
||||
Reference in New Issue
Block a user