gocritic (1/2) (#3836)

Add gocritic as a linter

    The linting is not complete, but should i complete in this PR or in a following.

    23 files have been touched so it may be better to do in a following PR


Commits:

* Add gocritic to linting

- Added gocritic to linting

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* gocritic

* pr comments

* remove switch in cmdBatch
This commit is contained in:
Marko
2019-08-01 10:28:32 -07:00
committed by Jack Zampolin
parent 5c9d6d839e
commit 513a32a6e3
23 changed files with 89 additions and 123 deletions
+2 -2
View File
@@ -54,7 +54,7 @@ func (privKey PrivKeyEd25519) Bytes() []byte {
// incorrect signature.
func (privKey PrivKeyEd25519) Sign(msg []byte) ([]byte, error) {
signatureBytes := ed25519.Sign(privKey[:], msg)
return signatureBytes[:], nil
return signatureBytes, nil
}
// PubKey gets the corresponding public key from the private key.
@@ -100,7 +100,7 @@ func GenPrivKey() PrivKeyEd25519 {
// genPrivKey generates a new ed25519 private key using the provided reader.
func genPrivKey(rand io.Reader) PrivKeyEd25519 {
seed := make([]byte, 32)
_, err := io.ReadFull(rand, seed[:])
_, err := io.ReadFull(rand, seed)
if err != nil {
panic(err)
}
+2 -2
View File
@@ -24,10 +24,10 @@ func (zeroReader) Read(buf []byte) (int, error) {
// BenchmarkKeyGeneration benchmarks the given key generation algorithm using
// a dummy reader.
func BenchmarkKeyGeneration(b *testing.B, GenerateKey func(reader io.Reader) crypto.PrivKey) {
func BenchmarkKeyGeneration(b *testing.B, generateKey func(reader io.Reader) crypto.PrivKey) {
var zero zeroReader
for i := 0; i < b.N; i++ {
GenerateKey(zero)
generateKey(zero)
}
}
@@ -30,6 +30,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// nolint:gocritic
package secp256k1
import (