Skip to content

Commit a852e7b

Browse files
authored
lint: fixing linter errs (#100)
1 parent dbf54fc commit a852e7b

File tree

4 files changed

+8
-27
lines changed

4 files changed

+8
-27
lines changed

.github/workflows/lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ jobs:
1414
- uses: actions/checkout@v4
1515
with:
1616
path: src/github.com/unrolled/secure
17-
- uses: golangci/golangci-lint-action@v4
17+
- uses: golangci/golangci-lint-action@v6
1818
with:
1919
working-directory: src/github.com/unrolled/secure

.golangci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ linters:
2929
- maintidx
3030
- contextcheck
3131
- perfsprint
32+
- exportloopref

secure.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ type Options struct {
9898
// AllowedHostsAreRegex determines, if the provided `AllowedHosts` slice contains valid regular expressions. If this flag is set to true, every request's host will be checked against these expressions. Default is false.
9999
AllowedHostsAreRegex bool
100100
// AllowRequestFunc is a custom function that allows you to determine if the request should proceed or not based on your own custom logic. Default is nil.
101-
AllowRequestFunc AllowRequestFunc `json:"-" yaml:"-" toml:"-"`
101+
AllowRequestFunc AllowRequestFunc `json:"-" toml:"-" yaml:"-"`
102102
// HostsProxyHeaders is a set of header keys that may hold a proxied hostname value for the request.
103103
HostsProxyHeaders []string
104104
// SSLHostFunc is a function pointer, the return value of the function is the host name that has same functionality as `SSHost`. Default is nil.
105105
// If SSLHostFunc is nil, the `SSLHost` option will be used.
106-
SSLHostFunc *SSLHostFunc `json:"-" yaml:"-" toml:"-"`
106+
SSLHostFunc *SSLHostFunc `json:"-" toml:"-" yaml:"-"`
107107
// SSLProxyHeaders is set of header keys with associated values that would indicate a valid https request. Useful when using Nginx: `map[string]string{"X-Forwarded-Proto": "https"}`. Default is blank map.
108108
SSLProxyHeaders map[string]string
109109
// STSSeconds is the max-age of the Strict-Transport-Security header. Default is 0, which would NOT include the header.

secure_test.go

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,35 +1376,15 @@ func TestBadRequestHandler(t *testing.T) {
13761376
}
13771377

13781378
func TestMarshal(t *testing.T) {
1379-
// func cant be marshalled
1380-
var t1 = struct {
1381-
A string
1382-
F func()
1383-
}{}
1384-
_, err := json.Marshal(t1) //lint:ignore SA1026 ignore marshal error
1385-
if err == nil {
1386-
t.Error("expected error got none")
1387-
} else if !strings.Contains(err.Error(), "unsupported type: func()") {
1388-
t.Error("unexpected error:", err)
1389-
}
1390-
1391-
// struct field tags omits func
1392-
var t2 = struct {
1393-
A string
1394-
F func() `json:"-"`
1395-
}{}
1396-
_, err = json.Marshal(t2)
1397-
if err != nil {
1398-
t.Error("unexpected error:", err)
1399-
}
1400-
14011379
// Options has struct field tags to omit func fields
14021380
var o1 Options
1403-
b, err := json.Marshal(o1)
1381+
1382+
b, err := json.Marshal(o1) //nolint:musttag
14041383
if err != nil {
14051384
t.Errorf("unexpected error marshal: %v", err)
14061385
}
1407-
err = json.Unmarshal(b, &o1)
1386+
1387+
err = json.Unmarshal(b, &o1) //nolint:musttag
14081388
if err != nil {
14091389
t.Errorf("unexpected error unmarshal: %v", err)
14101390
}

0 commit comments

Comments
 (0)