Skip to content

Commit

Permalink
Merge pull request #1121 from cornelk/fix_import_grouping
Browse files Browse the repository at this point in the history
chore: fix import grouping, code formatting and enable goimports linter
  • Loading branch information
jacobbednarz committed Oct 31, 2022
2 parents b8b256c + 9e59eda commit a69a4af
Show file tree
Hide file tree
Showing 42 changed files with 112 additions and 125 deletions.
3 changes: 3 additions & 0 deletions .changelog/1121.txt
@@ -0,0 +1,3 @@
```release-note:enhancement
deps: fix import grouping, code formatting and enable goimports linter
```
1 change: 1 addition & 0 deletions .golintci.yaml
Expand Up @@ -32,6 +32,7 @@ linters:
- exportloopref # prevent scope issues with pointers in loops.
- goconst # use constants where values are repeated.
- reassign # checks that package variables are not reassigned.
- goimports # checks import grouping and code formatting.

output:
format: colored-line-number
3 changes: 1 addition & 2 deletions cmd/flarectl/firewall.go
Expand Up @@ -2,13 +2,12 @@ package main

import (
"context"
"errors"
"fmt"
"net"
"os"
"strconv"

"errors"

"github.com/cloudflare/cloudflare-go"
"github.com/urfave/cli/v2"
)
Expand Down
7 changes: 3 additions & 4 deletions cmd/flarectl/misc.go
Expand Up @@ -3,12 +3,11 @@ package main
import (
"context"
"encoding/json"
"errors"
"fmt"
"os"
"strings"

"errors"

cloudflare "github.com/cloudflare/cloudflare-go"
"github.com/olekukonko/tablewriter"
"github.com/urfave/cli/v2"
Expand Down Expand Up @@ -46,7 +45,7 @@ func initializeAPI(c *cli.Context) error {
}

if c.IsSet("account-id") {
cloudflare.UsingAccount(c.String("account-id"))(api) //nolint
cloudflare.UsingAccount(c.String("account-id"))(api) // nolint
}

return nil
Expand Down Expand Up @@ -93,7 +92,7 @@ func writeTable(c *cli.Context, data [][]string, cols ...string) {
func checkFlags(c *cli.Context, flags ...string) error {
for _, flag := range flags {
if c.String(flag) == "" {
cli.ShowSubcommandHelp(c) //nolint
cli.ShowSubcommandHelp(c) // nolint
err := fmt.Errorf("error: the required flag %q was empty or not provided", flag)
fmt.Fprintln(os.Stderr, err)
return err
Expand Down
38 changes: 19 additions & 19 deletions convert_types.go
Expand Up @@ -22,26 +22,26 @@ import (
// AnyPtr is a helper routine that allocates a new interface value
// to store v and returns a pointer to it.
//
// // Usage: var _ *Type = AnyPtr(Type(value) | value).(*Type)
// Usage: var _ *Type = AnyPtr(Type(value) | value).(*Type)
//
// var _ *bool = AnyPtr(true).(*bool)
// var _ *byte = AnyPtr(byte(1)).(*byte)
// var _ *complex64 = AnyPtr(complex64(1.1)).(*complex64)
// var _ *complex128 = AnyPtr(complex128(1.1)).(*complex128)
// var _ *float32 = AnyPtr(float32(1.1)).(*float32)
// var _ *float64 = AnyPtr(float64(1.1)).(*float64)
// var _ *int = AnyPtr(int(1)).(*int)
// var _ *int8 = AnyPtr(int8(8)).(*int8)
// var _ *int16 = AnyPtr(int16(16)).(*int16)
// var _ *int32 = AnyPtr(int32(32)).(*int32)
// var _ *int64 = AnyPtr(int64(64)).(*int64)
// var _ *rune = AnyPtr(rune(1)).(*rune)
// var _ *string = AnyPtr("ptr").(*string)
// var _ *uint = AnyPtr(uint(1)).(*uint)
// var _ *uint8 = AnyPtr(uint8(8)).(*uint8)
// var _ *uint16 = AnyPtr(uint16(16)).(*uint16)
// var _ *uint32 = AnyPtr(uint32(32)).(*uint32)
// var _ *uint64 = AnyPtr(uint64(64)).(*uint64)
// var _ *bool = AnyPtr(true).(*bool)
// var _ *byte = AnyPtr(byte(1)).(*byte)
// var _ *complex64 = AnyPtr(complex64(1.1)).(*complex64)
// var _ *complex128 = AnyPtr(complex128(1.1)).(*complex128)
// var _ *float32 = AnyPtr(float32(1.1)).(*float32)
// var _ *float64 = AnyPtr(float64(1.1)).(*float64)
// var _ *int = AnyPtr(int(1)).(*int)
// var _ *int8 = AnyPtr(int8(8)).(*int8)
// var _ *int16 = AnyPtr(int16(16)).(*int16)
// var _ *int32 = AnyPtr(int32(32)).(*int32)
// var _ *int64 = AnyPtr(int64(64)).(*int64)
// var _ *rune = AnyPtr(rune(1)).(*rune)
// var _ *string = AnyPtr("ptr").(*string)
// var _ *uint = AnyPtr(uint(1)).(*uint)
// var _ *uint8 = AnyPtr(uint8(8)).(*uint8)
// var _ *uint16 = AnyPtr(uint16(16)).(*uint16)
// var _ *uint32 = AnyPtr(uint32(32)).(*uint32)
// var _ *uint64 = AnyPtr(uint64(64)).(*uint64)
func AnyPtr(v interface{}) interface{} {
r := reflect.New(reflect.TypeOf(v))
reflect.ValueOf(r.Interface()).Elem().Set(reflect.ValueOf(v))
Expand Down
7 changes: 3 additions & 4 deletions custom_hostname.go
Expand Up @@ -3,13 +3,12 @@ package cloudflare
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
"time"

"errors"
)

// CustomHostnameStatus is the enumeration of valid state values in the CustomHostnameSSL.
Expand Down Expand Up @@ -38,14 +37,14 @@ type CustomHostnameSSLSettings struct {
EarlyHints string `json:"early_hints,omitempty"`
}

//CustomHostnameOwnershipVerification represents ownership verification status of a given custom hostname.
// CustomHostnameOwnershipVerification represents ownership verification status of a given custom hostname.
type CustomHostnameOwnershipVerification struct {
Type string `json:"type,omitempty"`
Name string `json:"name,omitempty"`
Value string `json:"value,omitempty"`
}

//SSLValidationError represents errors that occurred during SSL validation.
// SSLValidationError represents errors that occurred during SSL validation.
type SSLValidationError struct {
Message string `json:"message,omitempty"`
}
Expand Down
3 changes: 1 addition & 2 deletions errors.go
@@ -1,11 +1,10 @@
package cloudflare

import (
"errors"
"fmt"
"net/http"
"strings"

"errors"
)

const (
Expand Down
3 changes: 1 addition & 2 deletions filter.go
Expand Up @@ -3,11 +3,10 @@ package cloudflare
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"

"errors"
)

var ErrNotEnoughFilterIDsProvided = errors.New("at least one filter ID must be provided.")
Expand Down
3 changes: 1 addition & 2 deletions images.go
Expand Up @@ -4,13 +4,12 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"mime/multipart"
"net/http"
"time"

"errors"
)

// Image represents a Cloudflare Image.
Expand Down
3 changes: 2 additions & 1 deletion intelligence_asn_test.go
Expand Up @@ -3,9 +3,10 @@ package cloudflare
import (
"context"
"fmt"
"github.com/stretchr/testify/assert"
"net/http"
"testing"

"github.com/stretchr/testify/assert"
)

const testASNNumber = "13335"
Expand Down
3 changes: 2 additions & 1 deletion intelligence_domain_test.go
Expand Up @@ -3,9 +3,10 @@ package cloudflare
import (
"context"
"fmt"
"github.com/stretchr/testify/assert"
"net/http"
"testing"

"github.com/stretchr/testify/assert"
)

func TestIntelligence_DomainDetails(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion intelligence_ip_test.go
Expand Up @@ -3,9 +3,10 @@ package cloudflare
import (
"context"
"fmt"
"github.com/stretchr/testify/assert"
"net/http"
"testing"

"github.com/stretchr/testify/assert"
)

func TestIntelligence_GetIPOverview(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion intelligence_phishing_test.go
Expand Up @@ -3,9 +3,10 @@ package cloudflare
import (
"context"
"fmt"
"github.com/stretchr/testify/assert"
"net/http"
"testing"

"github.com/stretchr/testify/assert"
)

func TestIntelligence_PhishingScan(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion intelligence_whois_test.go
Expand Up @@ -3,9 +3,10 @@ package cloudflare
import (
"context"
"fmt"
"github.com/stretchr/testify/assert"
"net/http"
"testing"

"github.com/stretchr/testify/assert"
)

func TestIntelligence_WHOIS(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions ip_list.go
Expand Up @@ -3,11 +3,10 @@ package cloudflare
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"time"

"errors"
)

// The definitions in this file are deprecated and should be removed after
Expand Down
3 changes: 1 addition & 2 deletions list.go
Expand Up @@ -3,11 +3,10 @@ package cloudflare
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"time"

"errors"
)

const (
Expand Down
3 changes: 1 addition & 2 deletions logpush.go
Expand Up @@ -3,11 +3,10 @@ package cloudflare
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"time"

"errors"
)

// LogpushJob describes a Logpush job.
Expand Down
3 changes: 1 addition & 2 deletions magic_firewall_rulesets.go
Expand Up @@ -3,11 +3,10 @@ package cloudflare
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"time"

"errors"
)

const (
Expand Down
3 changes: 1 addition & 2 deletions magic_transit_gre_tunnel.go
Expand Up @@ -3,11 +3,10 @@ package cloudflare
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"time"

"errors"
)

// Magic Transit GRE Tunnel Error messages.
Expand Down
3 changes: 1 addition & 2 deletions magic_transit_ipsec_tunnel.go
Expand Up @@ -3,11 +3,10 @@ package cloudflare
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"time"

"errors"
)

// Magic Transit IPsec Tunnel Error messages.
Expand Down
3 changes: 1 addition & 2 deletions magic_transit_static_routes.go
Expand Up @@ -3,11 +3,10 @@ package cloudflare
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"time"

"errors"
)

// Magic Transit Static Routes Error messages.
Expand Down
3 changes: 2 additions & 1 deletion miscategorization_test.go
Expand Up @@ -3,9 +3,10 @@ package cloudflare
import (
"context"
"fmt"
"github.com/stretchr/testify/assert"
"net/http"
"testing"

"github.com/stretchr/testify/assert"
)

func TestCreateMiscategorization(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions origin_ca.go
Expand Up @@ -3,13 +3,12 @@ package cloudflare
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"net/url"
"time"

"errors"
)

// OriginCACertificate represents a Cloudflare-issued certificate.
Expand Down

0 comments on commit a69a4af

Please sign in to comment.