Fix golangci-lint warnings

main
Jan Dittberner 1 year ago
parent 175a72298d
commit 4c24e4692b

@ -27,9 +27,10 @@ import (
"sync"
"time"
"git.cacert.org/cacert-gosigner/pkg/messages"
"github.com/justincpresley/go-cobs"
"github.com/shamaton/msgpackgen/msgpack"
"git.cacert.org/cacert-gosigner/pkg/messages"
)
const cobsDelimiter = 0x00
@ -94,7 +95,7 @@ func (c *clientSimulator) handleInput(ctx context.Context) error {
default:
count, err := os.Stdin.Read(buf)
if err != nil {
return err
return fmt.Errorf("reading input failed: %w", err)
}
if count == 0 {
@ -107,7 +108,7 @@ func (c *clientSimulator) handleInput(ctx context.Context) error {
err = cobs.Verify(data, cobsConfig)
if err != nil {
return err
return fmt.Errorf("frame verification failed: %w", err)
}
c.responses <- cobs.Decode(data, cobsConfig)
@ -157,7 +158,7 @@ func (c *clientSimulator) Run() error {
var inputError, commandError error
go func(inputErr error) {
inputError = c.handleInput(ctx)
_ = c.handleInput(ctx)
cancel()
@ -165,7 +166,7 @@ func (c *clientSimulator) Run() error {
}(inputError)
go func(commandErr error) {
commandErr = c.handleCommands(ctx)
_ = c.handleCommands(ctx)
cancel()

@ -4,6 +4,7 @@ package messages
import (
"fmt"
msgpack "github.com/shamaton/msgpackgen/msgpack"
dec "github.com/shamaton/msgpackgen/msgpack/dec"
enc "github.com/shamaton/msgpackgen/msgpack/enc"

@ -1,3 +1,20 @@
/*
Copyright 2022 CAcert Inc.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package helper
import (
@ -9,7 +26,7 @@ import (
// GenerateRandomSerial generates a random serial number to be used in X.509 certificates. The implementation is
// compliant to https://www.rfc-editor.org/rfc/rfc5280#section-4.1.2.2.
func GenerateRandomSerial() (*big.Int, error) {
serial, err := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 160))
serial, err := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 160)) //nolint:gomnd
if err != nil {
return nil, fmt.Errorf("could not generate random serial number: %w", err)
}

@ -1,10 +1,28 @@
/*
Copyright 2022 CAcert Inc.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package helper_test
import (
"testing"
"git.cacert.org/cacert-gosigner/pkg/x509/helper"
"github.com/stretchr/testify/assert"
"git.cacert.org/cacert-gosigner/pkg/x509/helper"
)
func TestGenerateRandomSerial(t *testing.T) {

@ -28,10 +28,11 @@ import (
"math/big"
"testing"
"git.cacert.org/cacert-gosigner/pkg/x509/helper"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"git.cacert.org/cacert-gosigner/pkg/x509/helper"
"git.cacert.org/cacert-gosigner/pkg/x509/revoking"
)

@ -28,9 +28,10 @@ import (
"testing"
"time"
"git.cacert.org/cacert-gosigner/pkg/x509/helper"
"github.com/stretchr/testify/assert"
"git.cacert.org/cacert-gosigner/pkg/x509/helper"
"git.cacert.org/cacert-gosigner/pkg/x509/signing"
)

Loading…
Cancel
Save