Skip to content

Commit

Permalink
go: Reformat code using gofumpt
Browse files Browse the repository at this point in the history
  • Loading branch information
kostko committed Jul 10, 2020
1 parent 83ee2e9 commit 533c4d8
Show file tree
Hide file tree
Showing 121 changed files with 400 additions and 458 deletions.
1 change: 1 addition & 0 deletions go/common/crypto/mrae/deoxysii/asymmetric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/oasisprotocol/deoxysii"

"github.com/oasisprotocol/oasis-core/go/common/crypto/mrae/api"
)

Expand Down
2 changes: 1 addition & 1 deletion go/common/crypto/signature/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const (

pubPEMType = "ED25519 PUBLIC KEY"
sigPEMType = "ED25519 SIGNATURE"
filePerm = 0600
filePerm = 0o600
)

var (
Expand Down
2 changes: 1 addition & 1 deletion go/common/crypto/signature/signers/file/file_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
const (
privateKeyPemType = "ED25519 PRIVATE KEY"

filePerm = 0600
filePerm = 0o600

// SignerName is the name used to identify the file backed signer.
SignerName = "file"
Expand Down
4 changes: 2 additions & 2 deletions go/common/crypto/tls/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ func Save(certPath, keyPath string, cert *tls.Certificate) error {
return err
}

if err = ioutil.WriteFile(keyPath, keyPEM, 0600); err != nil {
if err = ioutil.WriteFile(keyPath, keyPEM, 0o600); err != nil {
return fmt.Errorf("tls: failed to write private key: %w", err)
}

if err = ioutil.WriteFile(certPath, certPEM, 0644); err != nil {
if err = ioutil.WriteFile(certPath, certPEM, 0o644); err != nil {
return fmt.Errorf("tls: failed to write certificate: %w", err)
}

Expand Down
12 changes: 8 additions & 4 deletions go/common/encoding/bech32/bech32_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,20 @@ func TestBIP173(t *testing.T) {
// HRP character out of range.
{"\x801eym55h", false, "decoding bech32 failed: invalid character in string: '\u0080'"},
// Overall max length exceeded.
{"an84characterslonghumanreadablepartthatcontainsthenumber1andtheexcludedcharactersbio1569pvx",
{
"an84characterslonghumanreadablepartthatcontainsthenumber1andtheexcludedcharactersbio1569pvx",
false,
"decoding bech32 failed: invalid bech32 string length 91"},
"decoding bech32 failed: invalid bech32 string length 91",
},
// No separator character.
{"pzry9x0s0muk", false, "decoding bech32 failed: invalid index of 1"},
// Empty HRP.
{"1pzry9x0s0muk", false, "decoding bech32 failed: invalid index of 1"},
// Invalid data character.
{"x1b4n0q5v", false,
"decoding bech32 failed: failed converting data to bytes: invalid character not part of charset: 98"},
{
"x1b4n0q5v", false,
"decoding bech32 failed: failed converting data to bytes: invalid character not part of charset: 98",
},
// Too short checksum.
{"li1dgmt3", false, "decoding bech32 failed: invalid index of 1"},
// Invalid character in checksum.
Expand Down
2 changes: 1 addition & 1 deletion go/common/entity/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
const (
entityFilename = "entity.json"

fileMode = 0600
fileMode = 0o600
)

var (
Expand Down
14 changes: 7 additions & 7 deletions go/common/fuzz/fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ type InterfaceFuzzer struct {

methodList []int

typeOverrides map[string]func()interface{}
typeOverrides map[string]func() interface{}
}

// OverrideType registers a custom callback for creating instances of a given type.
func (i *InterfaceFuzzer) OverrideType(typeName string, factory func()interface{}) {
func (i *InterfaceFuzzer) OverrideType(typeName string, factory func() interface{}) {
i.typeOverrides[typeName] = factory
}

Expand Down Expand Up @@ -110,11 +110,11 @@ FilterLoop:
func NewInterfaceFuzzer(instance interface{}) *InterfaceFuzzer {
val := reflect.ValueOf(instance)
ret := &InterfaceFuzzer{
instance: instance,
typeObject: val.Type(),
valObject: val,
typeOverrides: map[string]func()interface{}{
"context.Context": func()interface{}{
instance: instance,
typeObject: val.Type(),
valObject: val,
typeOverrides: map[string]func() interface{}{
"context.Context": func() interface{} {
return context.Background()
},
},
Expand Down
2 changes: 0 additions & 2 deletions go/common/grpc/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func UnaryServerInterceptor(authFunc AuthenticationFunction) grpc.UnaryServerInt
req interface{},
info *grpc.UnaryServerInfo,
handler grpc.UnaryHandler) (interface{}, error) {

overrideSrv, ok := info.Server.(ServerAuth)
if !ok {
// Server doesn't implement Authentication.
Expand Down Expand Up @@ -61,7 +60,6 @@ func StreamServerInterceptor(authFunc AuthenticationFunction) grpc.StreamServerI
stream grpc.ServerStream,
info *grpc.StreamServerInfo,
handler grpc.StreamHandler) error {

overrideSrv, ok := srv.(ServerAuth)
if !ok {
// Server doesn't implement Authentication.
Expand Down
1 change: 0 additions & 1 deletion go/common/grpc/auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,4 @@ func testAuth(t *testing.T, testCase *testCase) {
}

}

}
2 changes: 1 addition & 1 deletion go/common/grpc/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func errorToGrpc(err error) error {
Code: int32(status.Code(err)),
Message: err.Error(),
Details: []*any.Any{
&any.Any{
{
// Double serialization seems ugly, but there is no way around
// it as the format for errors is predefined.
Value: cbor.Marshal(&grpcError{Module: module, Code: code}),
Expand Down
1 change: 0 additions & 1 deletion go/common/grpc/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ func (p *proxy) handler(srv interface{}, stream grpc.ServerStream) error {
p.upstreamConn,
method,
)

if err != nil {
return err
}
Expand Down
1 change: 0 additions & 1 deletion go/common/grpc/testing/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ func (s *pingServer) WatchPings(ctx context.Context, query *PingQuery) (<-chan *
case <-ctx.Done():
return
}

}
}()
typedCh := make(chan *PingResponse)
Expand Down
8 changes: 3 additions & 5 deletions go/common/grpc/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import (
"google.golang.org/grpc"
)

var (
// ErrServiceClosed is the error returned when the wrapper receives a message for a service whose
// interceptor has been removed.
ErrServiceClosed = errors.New("grpc/wrapper: received message for wrapped service with deregistered wrapper")
)
// ErrServiceClosed is the error returned when the wrapper receives a message for a service whose
// interceptor has been removed.
var ErrServiceClosed = errors.New("grpc/wrapper: received message for wrapped service with deregistered wrapper")

type wrappedResponse struct {
resp interface{}
Expand Down
10 changes: 4 additions & 6 deletions go/common/ledger/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@ const (
ListingPathIndex uint32 = 0
)

var (
// ListingDerivationPath is the path used to list and connect to devices by address.
ListingDerivationPath = []uint32{
PathPurposeBIP44, ListingPathCoinType, ListingPathAccount, ListingPathChange, ListingPathIndex,
}
)
// ListingDerivationPath is the path used to list and connect to devices by address.
var ListingDerivationPath = []uint32{
PathPurposeBIP44, ListingPathCoinType, ListingPathAccount, ListingPathChange, ListingPathIndex,
}

// Device is a Ledger device.
type Device = ledger.LedgerOasis
Expand Down
2 changes: 1 addition & 1 deletion go/common/mkdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
// Mkdir creates a directory iff it does not exist, and otherwise
// ensures that the filesystem permissions are sufficiently restrictive.
func Mkdir(d string) error {
const permDir = os.FileMode(0700)
const permDir = os.FileMode(0o700)

fi, err := os.Lstat(d)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion go/common/pubsub/pubsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ func testSubscribeEx(t *testing.T) {
require.NotNil(t, sub.ch, "Subscription, inner channel")
require.Equal(t, sub.ch, callbackCh, "Callback channel != Subscription, inner channel")
}

}

func testNewBrokerEx(t *testing.T) {
Expand Down
74 changes: 39 additions & 35 deletions go/common/sgx/aesm/aesm_proto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions go/common/sgx/ias/quote_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package ias

import (
"encoding/hex"
"testing"
"time"

"github.com/stretchr/testify/require"

"encoding/hex"
)

func TestQuote(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion go/common/sgx/sigstruct/sigstruct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestSigstruct(t *testing.T) {

// Generate a SIGSTRUCT.
builder := New(
WithBuildDate(time.Date(2016, 01, 9, 0, 0, 0, 0, time.UTC)),
WithBuildDate(time.Date(2016, 1, 9, 0, 0, 0, 0, time.UTC)),
WithAttributes(sgx.Attributes{
Flags: 0x04,
Xfrm: 0x03,
Expand Down
2 changes: 1 addition & 1 deletion go/common/tracing/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func SpanContextToBinary(sc opentracing.SpanContext) ([]byte, error) {
// SpanContext in binary format.
// Returns a new SpanContext instance using the global tracer.
func SpanContextFromBinary(scBinary []byte) (opentracing.SpanContext, error) {
var scReader = bytes.NewReader(scBinary)
scReader := bytes.NewReader(scBinary)
sc, err := opentracing.GlobalTracer().Extract(opentracing.Binary, scReader)

return sc, err
Expand Down
10 changes: 4 additions & 6 deletions go/consensus/tendermint/abci/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ import (
"github.com/oasisprotocol/oasis-core/go/storage/mkvs"
)

var (
// parametersKeyFmt is the key format used for consensus parameters.
//
// Value is CBOR-serialized consensusGenesis.Parameters.
parametersKeyFmt = keyformat.New(0xF1)
)
// parametersKeyFmt is the key format used for consensus parameters.
//
// Value is CBOR-serialized consensusGenesis.Parameters.
var parametersKeyFmt = keyformat.New(0xF1)

// ImmutableState is an immutable consensus backend state wrapper.
type ImmutableState struct {
Expand Down
6 changes: 2 additions & 4 deletions go/consensus/tendermint/api/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ import (
"github.com/oasisprotocol/oasis-core/go/storage/mkvs"
)

var (
// ErrNoState is the error returned when state is nil.
ErrNoState = errors.New("tendermint: no state available (app not registered?)")
)
// ErrNoState is the error returned when state is nil.
var ErrNoState = errors.New("tendermint: no state available (app not registered?)")

// ApplicationState is the overall past, present and future state of all multiplexed applications.
type ApplicationState interface {
Expand Down
10 changes: 4 additions & 6 deletions go/consensus/tendermint/apps/keymanager/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ import (
"github.com/oasisprotocol/oasis-core/go/storage/mkvs"
)

var (
// statusKeyFmt is the key manager status key format.
//
// Value is CBOR-serialized key manager status.
statusKeyFmt = keyformat.New(0x70, keyformat.H(&common.Namespace{}))
)
// statusKeyFmt is the key manager status key format.
//
// Value is CBOR-serialized key manager status.
var statusKeyFmt = keyformat.New(0x70, keyformat.H(&common.Namespace{}))

// ImmutableState is the immutable key manager state wrapper.
type ImmutableState struct {
Expand Down
Loading

0 comments on commit 533c4d8

Please sign in to comment.