This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git
The following commit(s) were added to refs/heads/main by this push:
new 21648e7 chore(deps): bump up go version (#251)
21648e7 is described below
commit 21648e752a1dad42cb46b50b38e77f0a8f15219c
Author: kezhenxu94 <[email protected]>
AuthorDate: Thu Nov 6 13:49:06 2025 +0800
chore(deps): bump up go version (#251)
---
.github/workflows/license-eye-check.yaml | 10 +-
.golangci.yml | 190 ++++++++++++++++---------------
Dockerfile | 2 +-
Makefile | 2 +-
action.yml | 4 +-
dependency/action.yml | 4 +-
examples/golang/Dockerfile | 2 +-
go.mod | 4 +-
header/action.yml | 4 +-
pkg/deps/cargo_test.go | 49 ++++----
pkg/deps/category_matrix_test.go | 1 +
pkg/deps/jar_test.go | 14 ++-
pkg/deps/maven_test.go | 29 +++--
pkg/deps/npm_test.go | 4 +-
pkg/deps/ruby_test.go | 10 +-
pkg/header/check_test.go | 20 ++--
pkg/header/fix_test.go | 5 +-
test/content_test.go | 7 +-
18 files changed, 181 insertions(+), 180 deletions(-)
diff --git a/.github/workflows/license-eye-check.yaml
b/.github/workflows/license-eye-check.yaml
index d7edee1..dfeb8c2 100644
--- a/.github/workflows/license-eye-check.yaml
+++ b/.github/workflows/license-eye-check.yaml
@@ -16,37 +16,29 @@
# under the License.
name: LicenseEye
-
on:
pull_request:
push:
branches:
- main
-
jobs:
build-license-eye:
name: Build LicenseEye
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
-
- uses: actions/setup-go@v5
with:
- go-version: 1.23
-
+ go-version: 1.25
- name: Lint Codes
run: make lint
-
- name: License Check
run: make license
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
- name: Test
run: make test
-
- name: Build
run: make build
-
- name: Build Docker Image
run: make docker
diff --git a/.golangci.yml b/.golangci.yml
index 657b499..fc05050 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -15,112 +15,116 @@
# specific language governing permissions and limitations
# under the License.
-run:
- tests: false
-
-linters-settings:
- govet:
- enable:
- - shadow
- revive:
- min-confidence: 0
- gocyclo:
- min-complexity: 20
- maligned:
- suggest-new: true
- dupl:
- threshold: 200
- goconst:
- min-len: 2
- min-occurrences: 2
- depguard:
- rules:
- main:
- deny:
- - pkg: "fmt"
- desc: "logging is allowed only by logutils.Log"
- misspell:
- locale: US
- ignore-words:
- - analogue
- - analyse
- - artefact
- - authorised
- - calibre
- - cancelled
- - catalogue
- - categorise
- - centre
- - emphasised
- - favour
- - favourite
- - fulfil
- - fulfilment
- - initialise
- - labelling
- - labour
- - licence
- - maximise
- - modelled
- - modelling
- - offence
- - optimise
- - organisation
- - organise
- - practise
- - programme
- - realise
- - recognise
- - signalling
- - utilisation
- lll:
- line-length: 150
- goimports:
- local-prefixes: github.com/apache/skywalking-eyes
- gocritic:
- enabled-tags:
- - diagnostic
- - experimental
- - opinionated
- - performance
- - style
- disabled-checks:
- - ifElseChain
- funlen:
- lines: 100
- statements: 50
- whitespace:
- multi-if: false
- multi-func: false
-
+version: "2"
linters:
enable:
- bodyclose
- - errcheck
- dogsled
- dupl
- funlen
- goconst
- gocritic
- gocyclo
- - gofmt
- - goimports
- - revive
- gosec
- - gosimple
- - govet
- - ineffassign
- lll
- misspell
- nakedret
- - staticcheck
- - typecheck
+ - revive
- unconvert
- unparam
- - unused
- whitespace
-
-service:
- golangci-lint-version: 1.63.4
- prepare:
- - echo "here I can run custom commands, but no preparation needed for this
repo"
+ settings:
+ depguard:
+ rules:
+ main:
+ deny:
+ - pkg: fmt
+ desc: logging is allowed only by logutils.Log
+ dupl:
+ threshold: 200
+ funlen:
+ lines: 200
+ statements: 50
+ goconst:
+ min-len: 2
+ min-occurrences: 2
+ gocritic:
+ disabled-checks:
+ - ifElseChain
+ enabled-tags:
+ - diagnostic
+ - experimental
+ - opinionated
+ - performance
+ - style
+ govet:
+ enable:
+ - shadow
+ lll:
+ line-length: 150
+ misspell:
+ locale: US
+ ignore-rules:
+ - analogue
+ - analyse
+ - artefact
+ - authorised
+ - calibre
+ - cancelled
+ - catalogue
+ - categorise
+ - centre
+ - emphasised
+ - favour
+ - favourite
+ - fulfil
+ - fulfilment
+ - initialise
+ - labelling
+ - labour
+ - licence
+ - maximise
+ - modelled
+ - modelling
+ - offence
+ - optimise
+ - organisation
+ - organise
+ - practise
+ - programme
+ - realise
+ - recognise
+ - signalling
+ - utilisation
+ whitespace:
+ multi-if: false
+ multi-func: false
+ exclusions:
+ generated: lax
+ presets:
+ - comments
+ - common-false-positives
+ - legacy
+ - std-error-handling
+ paths:
+ - third_party$
+ - builtin$
+ - examples$
+ rules:
+ - linters:
+ - funlen
+ path: _test\.go
+formatters:
+ enable:
+ - gofmt
+ - goimports
+ settings:
+ goimports:
+ local-prefixes:
+ - github.com/apache/skywalking-eyes
+ exclusions:
+ generated: lax
+ paths:
+ - third_party$
+ - builtin$
+ - examples$
diff --git a/Dockerfile b/Dockerfile
index 88e76e8..bd2d79e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-FROM golang:1.23-alpine AS build
+FROM golang:1.25-alpine AS build
WORKDIR /license-eye
diff --git a/Makefile b/Makefile
index 2b7476d..30f3c6a 100644
--- a/Makefile
+++ b/Makefile
@@ -43,7 +43,7 @@ RELEASE_SRC = skywalking-$(PROJECT)-$(VERSION)-src
all: clean lint license test build
$(GO_LINT):
- curl -sfL
https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh
-s -- -b $(GO_PATH)/bin v1.63.4
+ curl -sfL
https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh
-s -- -b $(GO_PATH)/bin v2.6.1
.PHONY: lint
lint: $(GO_LINT)
diff --git a/action.yml b/action.yml
index b2fadeb..c0522c2 100644
--- a/action.yml
+++ b/action.yml
@@ -42,12 +42,12 @@ inputs:
required: false
default: check
runs:
- using: "composite"
+ using: composite
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
- go-version: 1.23
+ go-version: 1.25
cache-dependency-path: ${{ github.action_path }}/go.sum
- shell: bash
run: make -C $GITHUB_ACTION_PATH install
diff --git a/dependency/action.yml b/dependency/action.yml
index e9a87f1..852a385 100644
--- a/dependency/action.yml
+++ b/dependency/action.yml
@@ -40,12 +40,12 @@ inputs:
Extra flags appended to the command, for example,
--summary=path/to/template.tmpl
required: false
runs:
- using: "composite"
+ using: composite
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
- go-version: 1.23
+ go-version: 1.25
cache-dependency-path: ${{ github.action_path }}/go.sum
- shell: bash
run: make -C $GITHUB_ACTION_PATH/.. install
diff --git a/examples/golang/Dockerfile b/examples/golang/Dockerfile
index 021077b..656885e 100644
--- a/examples/golang/Dockerfile
+++ b/examples/golang/Dockerfile
@@ -17,7 +17,7 @@
FROM apache/skywalking-eyes:latest
-ARG GO_VERSION=1.23.1
+ARG GO_VERSION=1.25.3
ARG TARGETARCH
# Install Go
diff --git a/go.mod b/go.mod
index 6d39aff..485964b 100644
--- a/go.mod
+++ b/go.mod
@@ -1,8 +1,6 @@
module github.com/apache/skywalking-eyes
-go 1.23.0
-
-toolchain go1.23.6
+go 1.25.3
require (
github.com/Masterminds/sprig/v3 v3.2.3
diff --git a/header/action.yml b/header/action.yml
index 8ef7e17..f9bbb17 100644
--- a/header/action.yml
+++ b/header/action.yml
@@ -42,12 +42,12 @@ inputs:
required: false
default: check
runs:
- using: "composite"
+ using: composite
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
- go-version: 1.23
+ go-version: 1.25
cache-dependency-path: ${{ github.action_path }}/go.sum
- shell: bash
run: make -C $GITHUB_ACTION_PATH/.. install
diff --git a/pkg/deps/cargo_test.go b/pkg/deps/cargo_test.go
index a36a55a..0a11517 100644
--- a/pkg/deps/cargo_test.go
+++ b/pkg/deps/cargo_test.go
@@ -27,6 +27,18 @@ import (
"github.com/apache/skywalking-eyes/pkg/deps"
)
+const (
+ testCargoToml = `
+[package]
+name = "foo"
+version = "0.0.0"
+publish = false
+edition = "2021"
+license = "Apache-2.0"
+`
+ licenseMIT = "MIT"
+)
+
func TestCanResolveCargo(t *testing.T) {
resolver := new(deps.CargoTomlResolver)
if !resolver.CanResolve("Cargo.toml") {
@@ -45,14 +57,7 @@ func TestResolveCargos(t *testing.T) {
}
{
- cargoToml := `
-[package]
-name = "foo"
-version = "0.0.0"
-publish = false
-edition = "2021"
-license = "Apache-2.0"
-`
+ cargoToml := testCargoToml
config := deps.ConfigDeps{
Threshold: 0,
@@ -71,14 +76,7 @@ license = "Apache-2.0"
}
{
- cargoToml := `
-[package]
-name = "foo"
-version = "0.0.0"
-publish = false
-edition = "2021"
-license = "Apache-2.0"
-`
+ cargoToml := testCargoToml
config := deps.ConfigDeps{
Threshold: 0,
@@ -94,14 +92,7 @@ license = "Apache-2.0"
}
{
- cargoToml := `
-[package]
-name = "foo"
-version = "0.0.0"
-publish = false
-edition = "2021"
-license = "Apache-2.0"
-`
+ cargoToml := testCargoToml
config := deps.ConfigDeps{
Threshold: 0,
@@ -110,7 +101,7 @@ license = "Apache-2.0"
{
Name: "foo",
Version: "0.0.0",
- License: "MIT",
+ License: licenseMIT,
},
},
Excludes: []deps.Exclude{},
@@ -120,7 +111,7 @@ license = "Apache-2.0"
if len(report.Resolved) != 1 {
t.Error("len(report.Resolved) != 1")
}
- if report.Resolved[0].LicenseSpdxID != "MIT" {
+ if report.Resolved[0].LicenseSpdxID != licenseMIT {
t.Error("Package foo license isn't modified to MIT")
}
}
@@ -194,7 +185,7 @@ checksum =
"349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
}
}
-func resolveTmpCargo(t *testing.T, cargoTomlContent string, cargoLockContent
string, config *deps.ConfigDeps) *deps.Report {
+func resolveTmpCargo(t *testing.T, cargoTomlContent, cargoLockContent string,
config *deps.ConfigDeps) *deps.Report {
dir, err := os.MkdirTemp("", "skywalking-eyes-test-cargo-")
if err != nil {
t.Error("Make temp dir failed", err)
@@ -218,14 +209,14 @@ func resolveTmpCargo(t *testing.T, cargoTomlContent
string, cargoLockContent str
}
cargoFile := filepath.Join(dir, "Cargo.toml")
- if err := os.WriteFile(cargoFile, []byte(cargoTomlContent), 0644); err
!= nil {
+ if err := os.WriteFile(cargoFile, []byte(cargoTomlContent), 0o600); err
!= nil {
t.Error("Write Cargo.toml failed", err)
return nil
}
if cargoLockContent != "" {
cargoLockFile := filepath.Join(dir, "Cargo.lock")
- if err := os.WriteFile(cargoLockFile, []byte(cargoLockContent),
0644); err != nil {
+ if err := os.WriteFile(cargoLockFile, []byte(cargoLockContent),
0o600); err != nil {
t.Error("Write Cargo.lock failed", err)
return nil
}
diff --git a/pkg/deps/category_matrix_test.go b/pkg/deps/category_matrix_test.go
index bc66b37..f960491 100644
--- a/pkg/deps/category_matrix_test.go
+++ b/pkg/deps/category_matrix_test.go
@@ -33,6 +33,7 @@ import (
func TestCategoryACompatAndWeakCompat(t *testing.T) {
// Main license: MIT (Category A)
// 1) A with A should be compatible without weak flag
+ //nolint:revive,staticcheck // empty block is intentional - just
checking no error is returned
if err := deps.Check("MIT", &deps.ConfigDeps{}, false); err == nil {
// We didn't pass any dependencies; we need to assert behavior
through CheckWithMatrix using a crafted report.
}
diff --git a/pkg/deps/jar_test.go b/pkg/deps/jar_test.go
index d428fa1..520b5ba 100644
--- a/pkg/deps/jar_test.go
+++ b/pkg/deps/jar_test.go
@@ -19,7 +19,6 @@ package deps_test
import (
"fmt"
- "io/ioutil"
"os"
"os/exec"
"path/filepath"
@@ -48,7 +47,7 @@ func TestCanResolveJarFile(t *testing.T) {
}
}
-func copyJars(t *testing.T, pomFile, content string) ([]string, error) {
+func copyJars(_ *testing.T, pomFile, content string) ([]string, error) {
dir := filepath.Dir(pomFile)
if err := os.Chdir(dir); err != nil {
@@ -64,7 +63,7 @@ func copyJars(t *testing.T, pomFile, content string)
([]string, error) {
}
jars := []string{}
- files, err := ioutil.ReadDir(filepath.Join(dir, "lib"))
+ files, err := os.ReadDir(filepath.Join(dir, "lib"))
if err != nil {
return nil, err
}
@@ -98,7 +97,8 @@ func TestResolveJar(t *testing.T) {
}{
{`<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>apache</groupId>
@@ -140,11 +140,13 @@ func TestResolveJar(t *testing.T) {
t.Error(err)
return
}
-
}
}
if len(report.Resolved)+len(report.Skipped) != test.cnt {
- t.Errorf("the expected number of jar packages is: %d,
but actually: %d. result:\n%v", test.cnt,
len(report.Resolved)+len(report.Skipped), report.String())
+ t.Errorf(
+ "the expected number of jar packages is: %d,
but actually: %d. result:\n%v",
+ test.cnt,
len(report.Resolved)+len(report.Skipped), report.String(),
+ )
}
fmt.Println(report.String())
}
diff --git a/pkg/deps/maven_test.go b/pkg/deps/maven_test.go
index b9da207..0d749c3 100644
--- a/pkg/deps/maven_test.go
+++ b/pkg/deps/maven_test.go
@@ -49,7 +49,7 @@ func TestCanResolvePomFile(t *testing.T) {
}
func writeFile(fileName, content string) error {
- file, err := os.OpenFile(fileName, os.O_WRONLY|os.O_TRUNC|os.O_CREATE,
0777)
+ file, err := os.OpenFile(fileName, os.O_WRONLY|os.O_TRUNC|os.O_CREATE,
0o777)
if err != nil {
return err
}
@@ -66,13 +66,13 @@ func writeFile(fileName, content string) error {
}
func ensureDir(dirName string) error {
- return os.MkdirAll(dirName, 0777)
+ return os.MkdirAll(dirName, 0o777)
}
//go:embed testdata/maven/**/*
var testAssets embed.FS
-func copy(assetDir, destination string) error {
+func copyAssets(assetDir, destination string) error {
return fs.WalkDir(testAssets, assetDir, func(path string, d
fs.DirEntry, err error) error {
if err != nil {
return err
@@ -81,15 +81,17 @@ func copy(assetDir, destination string) error {
return nil
}
filename := filepath.Join(destination, strings.Replace(path,
assetDir, "", 1))
- if err := ensureDir(filepath.Dir(filename)); err != nil {
- return err
+ if dirErr := ensureDir(filepath.Dir(filename)); dirErr != nil {
+ return dirErr
}
content, err := testAssets.ReadFile(path)
if err != nil {
return err
}
- writeFile(filename, string(content))
+ if err := writeFile(filename, string(content)); err != nil {
+ return err
+ }
return nil
})
@@ -98,6 +100,8 @@ func copy(assetDir, destination string) error {
func TestResolveMaven(t *testing.T) {
resolver := new(deps.MavenPomResolver)
+ const mavenCasesDir = "testdata/maven/cases"
+
for _, test := range []struct {
workingDir string
testCase string
@@ -107,14 +111,14 @@ func TestResolveMaven(t *testing.T) {
{t.TempDir(), "exclude", 109},
{t.TempDir(), "exclude-recursive", 7},
} {
- if err := copy("testdata/maven/base", test.workingDir); err !=
nil {
+ if err := copyAssets("testdata/maven/base", test.workingDir);
err != nil {
t.Error(err)
}
- if err := copy(filepath.Join("testdata/maven/cases",
test.testCase), test.workingDir); err != nil {
+ if err := copyAssets(filepath.Join(mavenCasesDir,
test.testCase), test.workingDir); err != nil {
t.Error(err)
}
- config, err :=
config.NewConfigFromFile(filepath.Join(test.workingDir, "licenserc.yaml"))
+ cfg, err :=
config.NewConfigFromFile(filepath.Join(test.workingDir, "licenserc.yaml"))
if err != nil {
t.Error(err)
}
@@ -122,13 +126,16 @@ func TestResolveMaven(t *testing.T) {
pomFile := filepath.Join(test.workingDir, "pom.xml")
if resolver.CanResolve(pomFile) {
report := deps.Report{}
- if err := resolver.Resolve(pomFile,
config.Dependencies(), &report); err != nil {
+ if err := resolver.Resolve(pomFile, cfg.Dependencies(),
&report); err != nil {
t.Error(err)
return
}
if len(report.Resolved)+len(report.Skipped) != test.cnt
{
- t.Errorf("the expected number of jar packages
is: %d, but actually: %d. result:\n%v", test.cnt,
len(report.Resolved)+len(report.Skipped), report.String())
+ t.Errorf(
+ "the expected number of jar packages
is: %d, but actually: %d. result:\n%v",
+ test.cnt,
len(report.Resolved)+len(report.Skipped), report.String(),
+ )
}
}
}
diff --git a/pkg/deps/npm_test.go b/pkg/deps/npm_test.go
index 5d76110..fc4439b 100644
--- a/pkg/deps/npm_test.go
+++ b/pkg/deps/npm_test.go
@@ -18,7 +18,7 @@
package deps_test
import (
- "io/ioutil"
+ "os"
"testing"
"github.com/apache/skywalking-eyes/pkg/deps"
@@ -87,7 +87,7 @@ func TestResolvePkgFile(t *testing.T) {
resolver := new(deps.NpmResolver)
for _, data := range TestData {
result := &deps.Result{}
- f, err := ioutil.TempFile(dir, "*.json")
+ f, err := os.CreateTemp(dir, "*.json")
if err != nil {
t.Fatal(err)
}
diff --git a/pkg/deps/ruby_test.go b/pkg/deps/ruby_test.go
index 319991c..f548f85 100644
--- a/pkg/deps/ruby_test.go
+++ b/pkg/deps/ruby_test.go
@@ -30,7 +30,7 @@ import (
)
func writeFileRuby(fileName, content string) error {
- file, err := os.OpenFile(fileName, os.O_WRONLY|os.O_TRUNC|os.O_CREATE,
0777)
+ file, err := os.OpenFile(fileName, os.O_WRONLY|os.O_TRUNC|os.O_CREATE,
0o777)
if err != nil {
return err
}
@@ -46,7 +46,7 @@ func writeFileRuby(fileName, content string) error {
}
func ensureDirRuby(dirName string) error {
- return os.MkdirAll(dirName, 0777)
+ return os.MkdirAll(dirName, 0o777)
}
//go:embed testdata/ruby/**/*
@@ -61,8 +61,8 @@ func copyRuby(assetDir, destination string) error {
return nil
}
filename := filepath.Join(destination, strings.Replace(path,
assetDir, "", 1))
- if err := ensureDirRuby(filepath.Dir(filename)); err != nil {
- return err
+ if dirErr := ensureDirRuby(filepath.Dir(filename)); dirErr !=
nil {
+ return dirErr
}
content, err := rubyTestAssets.ReadFile(path)
if err != nil {
@@ -127,7 +127,7 @@ func (f roundTripFunc) RoundTrip(req *http.Request)
(*http.Response, error) { re
func TestRubyMissingSpecIsSkippedGracefully(t *testing.T) {
// Mock HTTP client to avoid real network: always return 404 Not Found
saved := httpClientRuby
- httpClientRuby = &http.Client{Transport: roundTripFunc(func(r
*http.Request) (*http.Response, error) {
+ httpClientRuby = &http.Client{Transport: roundTripFunc(func(_
*http.Request) (*http.Response, error) {
return &http.Response{
StatusCode: http.StatusNotFound,
Status: "404 Not Found",
diff --git a/pkg/header/check_test.go b/pkg/header/check_test.go
index 3c285c3..67436bc 100644
--- a/pkg/header/check_test.go
+++ b/pkg/header/check_test.go
@@ -113,10 +113,12 @@ func TestListFilesWithEmptyRepo(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- defer os.Chdir(originalDir)
+ defer func() {
+ _ = os.Chdir(originalDir)
+ }()
- if err := os.Chdir(tempDir); err != nil {
- t.Fatal(err)
+ if chErr := os.Chdir(tempDir); chErr != nil {
+ t.Fatal(chErr)
}
// Initialize an empty git repository
@@ -127,7 +129,7 @@ func TestListFilesWithEmptyRepo(t *testing.T) {
// Create a test file
testFile := filepath.Join(tempDir, "test.go")
- err = os.WriteFile(testFile, []byte("package main"), 0644)
+ err = os.WriteFile(testFile, []byte("package main"), 0o600)
if err != nil {
t.Fatal(err)
}
@@ -162,10 +164,12 @@ func TestListFilesWithWorktreeDetachedHEAD(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- defer os.Chdir(originalDir)
+ defer func() {
+ _ = os.Chdir(originalDir)
+ }()
- if err := os.Chdir(tempDir); err != nil {
- t.Fatal(err)
+ if chErr := os.Chdir(tempDir); chErr != nil {
+ t.Fatal(chErr)
}
// Initialize a git repository with a commit
@@ -176,7 +180,7 @@ func TestListFilesWithWorktreeDetachedHEAD(t *testing.T) {
// Create and commit a file
testFile := "test.go"
- err = os.WriteFile(testFile, []byte("package main"), 0644)
+ err = os.WriteFile(testFile, []byte("package main"), 0o600)
if err != nil {
t.Fatal(err)
}
diff --git a/pkg/header/fix_test.go b/pkg/header/fix_test.go
index 8b55898..d6414b0 100644
--- a/pkg/header/fix_test.go
+++ b/pkg/header/fix_test.go
@@ -22,8 +22,9 @@ import (
"regexp"
"testing"
- "github.com/apache/skywalking-eyes/pkg/comments"
"github.com/stretchr/testify/require"
+
+ "github.com/apache/skywalking-eyes/pkg/comments"
)
var config = &ConfigHeader{
@@ -365,7 +366,7 @@ namespace test\test2;
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
var r *regexp.Regexp
- if len(test.licensePattern) > 0 {
+ if test.licensePattern != "" {
r = regexp.MustCompile(test.licensePattern)
}
content := rewriteContent(test.style,
[]byte(test.content), test.licenseHeader, r)
diff --git a/test/content_test.go b/test/content_test.go
index d65c3d1..6015d4b 100644
--- a/test/content_test.go
+++ b/test/content_test.go
@@ -18,13 +18,14 @@
package test
import (
- "io/ioutil"
+ "os"
"path/filepath"
"strings"
"testing"
- "github.com/apache/skywalking-eyes/pkg/header"
"gopkg.in/yaml.v3"
+
+ "github.com/apache/skywalking-eyes/pkg/header"
)
var c struct {
@@ -32,7 +33,7 @@ var c struct {
}
func init() {
- content, err := ioutil.ReadFile("testdata/test-spdx-content.yaml")
+ content, err := os.ReadFile("testdata/test-spdx-content.yaml")
if err != nil {
panic(err)