Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit fc6dc45

Browse files
committed
add GoSec and Golangci-lint
1 parent bf980b3 commit fc6dc45

3 files changed

Lines changed: 49 additions & 2 deletions

File tree

.github/workflows/gosec.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
on: [push, pull_request]
2+
name: GoSec
3+
jobs:
4+
gosec:
5+
strategy:
6+
matrix:
7+
go-version: [1.18.x]
8+
os: [ubuntu-latest]
9+
runs-on: ${{ matrix.os }}
10+
steps:
11+
- name: Install Go
12+
uses: actions/setup-go@v3
13+
with:
14+
go-version: ${{ matrix.go-version }}
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
- name: Security Scan
18+
uses: securego/gosec@master
19+
with:
20+
args: '-fmt sarif -out results.sarif ./...'
21+
- name: Upload SARIF file
22+
uses: github/codeql-action/upload-sarif@v2
23+
with:
24+
# Path to SARIF file relative to the root of the repository
25+
sarif_file: results.sarif

.github/workflows/lint.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
on: [push, pull_request]
2+
name: Lint
3+
jobs:
4+
lint:
5+
strategy:
6+
matrix:
7+
go-version: [1.18.x]
8+
os: [ubuntu-latest]
9+
runs-on: ${{ matrix.os }}
10+
steps:
11+
- name: Install Go
12+
uses: actions/setup-go@v3
13+
with:
14+
go-version: ${{ matrix.go-version }}
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
- name: golangci-lint
18+
uses: golangci/golangci-lint-action@v3
19+
with:
20+
version: v1.49
21+
args: --tests=false

mapstructure.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ func (d *Decoder) decodeString(name string, data interface{}, val reflect.Value)
590590
case reflect.Uint8:
591591
var uints []uint8
592592
if dataKind == reflect.Array {
593+
// nolint:gosimple
593594
uints = make([]uint8, dataVal.Len(), dataVal.Len())
594595
for i := range uints {
595596
uints[i] = dataVal.Index(i).Interface().(uint8)
@@ -939,12 +940,12 @@ func (d *Decoder) decodeMapFromStruct(name string, dataVal reflect.Value, val re
939940
if tagValue[:index] == "-" {
940941
continue
941942
}
942-
// If "omitempty" is specified in the tag, it ignores empty values.
943+
// nolint:gosimple // If "omitempty" is specified in the tag, it ignores empty values.
943944
if strings.Index(tagValue[index+1:], "omitempty") != -1 && isEmptyValue(v) {
944945
continue
945946
}
946947

947-
// If "squash" is specified in the tag, we squash the field down.
948+
// nolint:gosimple // If "squash" is specified in the tag, we squash the field down.
948949
squash = squash || strings.Index(tagValue[index+1:], "squash") != -1
949950
if squash {
950951
// When squashing, the embedded type can be a pointer to a struct.

0 commit comments

Comments
 (0)