Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit b9a42a2

Browse files
committed
Update for golangci-lint 2.0
1 parent 8143a7e commit b9a42a2

32 files changed

+112
-114
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.go text eol=lf

.github/workflows/go.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,3 @@ jobs:
1919
run: |
2020
make generate-fake-stemcell-automation
2121
- uses: golangci/golangci-lint-action@v7
22-
if: ${{ matrix.os == 'windows-2019' }}
23-
- uses: golangci/golangci-lint-action@v7
24-
if: ${{ matrix.os != 'windows-2019' }}
25-
with:
26-
args: --enable goimports

.golangci.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
# https://golangci-lint.run/usage/configuration/
2-
run:
3-
timeout: 5m # 1m default times out on github-action runners
1+
version: "2"
42

5-
output:
6-
# Sort results by: filepath, line and column.
7-
sort-results: true
3+
linters:
4+
default: standard
85

9-
issues:
10-
max-issues-per-linter: 0
11-
max-same-issues: 0
6+
settings:
7+
errcheck:
8+
check-blank: true # assignment to blank identifier: `_ := someFunc()`.
9+
10+
formatters:
11+
enable:
12+
- goimports

commandparser/construct_messenger.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type ConstructCmdMessenger struct {
1010
}
1111

1212
func (m *ConstructCmdMessenger) printMessage(message string) {
13-
fmt.Fprintln(m.OutputChannel, message)
13+
fmt.Fprintln(m.OutputChannel, message) //nolint:errcheck
1414
}
1515

1616
func (m *ConstructCmdMessenger) ArgumentsNotProvided() {

commandparser/construct_validator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func (c *ConstructValidator) PopulatedArgs(args ...string) bool {
1717
}
1818

1919
func (c *ConstructValidator) LGPOInDirectory() bool {
20-
dir, _ := os.Getwd()
20+
dir, _ := os.Getwd() //nolint:errcheck
2121
_, err := os.Stat(filepath.Join(dir, "LGPO.zip"))
2222

2323
return err == nil

commandparser/construct_validator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var _ = Describe("ConstructValidator", func() {
4747
})
4848

4949
Describe("LGPOInDirectory", func() {
50-
wd, _ := os.Getwd()
50+
wd, _ := os.Getwd() //nolint:errcheck
5151
LGPOPath := filepath.Join(wd, "LGPO.zip")
5252

5353
It("should return true if LGPO exists in the directory", func() {

commandparser/help.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,24 @@ func (h *stembuildHelp) Execute(c context.Context, f *flag.FlagSet, args ...inte
6363

6464
func (h *stembuildHelp) Explain(w io.Writer) {
6565

66-
_, _ = fmt.Fprintf(w, "%s version %s, Windows Stemcell Building Tool\n\n", path.Base(os.Args[0]), version.Version)
67-
_, _ = fmt.Fprintf(w, "Usage: %s <global options> <command> <command flags>\n\n", path.Base(os.Args[0]))
66+
fmt.Fprintf(w, "%s version %s, Windows Stemcell Building Tool\n\n", path.Base(os.Args[0]), version.Version) //nolint:errcheck
67+
fmt.Fprintf(w, "Usage: %s <global options> <command> <command flags>\n\n", path.Base(os.Args[0])) //nolint:errcheck
6868

69-
_, _ = fmt.Fprint(w, "Commands:\n")
69+
fmt.Fprint(w, "Commands:\n") //nolint:errcheck
7070
for _, command := range *h.commands {
7171
if len(command.Name()) < 5 { // This help align the synopses when the commands are of different lengths
72-
_, _ = fmt.Fprintf(w, " %s\t\t%s\n", command.Name(), command.Synopsis())
72+
fmt.Fprintf(w, " %s\t\t%s\n", command.Name(), command.Synopsis()) //nolint:errcheck
7373
} else {
74-
_, _ = fmt.Fprintf(w, " %s\t%s\n", command.Name(), command.Synopsis())
74+
fmt.Fprintf(w, " %s\t%s\n", command.Name(), command.Synopsis()) //nolint:errcheck
7575
}
7676
}
7777

78-
_, _ = fmt.Fprint(w, "\nGlobal Options:\n")
78+
fmt.Fprint(w, "\nGlobal Options:\n") //nolint:errcheck
7979
h.topLevelFlags.VisitAll(func(f *flag.Flag) {
8080
if len(f.Name) > 1 {
81-
_, _ = fmt.Fprintf(w, " -%s\t%s\n", f.Name, f.Usage)
81+
fmt.Fprintf(w, " -%s\t%s\n", f.Name, f.Usage) //nolint:errcheck
8282
} else {
83-
_, _ = fmt.Fprintf(w, " -%s\t\t%s\n", f.Name, f.Usage)
83+
fmt.Fprintf(w, " -%s\t\t%s\n", f.Name, f.Usage) //nolint:errcheck
8484
}
8585
})
8686
}

commandparser/package_messenger.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ type PackageMessenger struct {
1010
}
1111

1212
func (m *PackageMessenger) InvalidOutputConfig(e error) {
13-
fmt.Fprintln(m.Output, e)
13+
fmt.Fprintln(m.Output, e) //nolint:errcheck
1414
}
1515

1616
func (m *PackageMessenger) CannotCreatePackager(e error) {
17-
fmt.Fprintln(m.Output, e)
17+
fmt.Fprintln(m.Output, e) //nolint:errcheck
1818
}
1919

2020
func (m *PackageMessenger) DoesNotHaveEnoughSpace(e error) {
21-
fmt.Fprintln(m.Output, e)
21+
fmt.Fprintln(m.Output, e) //nolint:errcheck
2222
}
2323

2424
func (m *PackageMessenger) SourceParametersAreInvalid(e error) {
25-
fmt.Fprintln(m.Output, e)
25+
fmt.Fprintln(m.Output, e) //nolint:errcheck
2626
}
2727

2828
func (m *PackageMessenger) PackageFailed(e error) {
29-
fmt.Fprintln(m.Output, e)
30-
fmt.Fprintln(m.Output, "Please provide the error logs to [email protected]")
29+
fmt.Fprintln(m.Output, e) //nolint:errcheck
30+
fmt.Fprintln(m.Output, "Please provide the error logs to [email protected]") //nolint:errcheck
3131
}

construct/messenger.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (m *Messenger) ExecutePostRebootWarning(warning string) {
8686
}
8787

8888
func (m *Messenger) UploadFileStarted(artifact string) {
89-
m.out.Write([]byte(fmt.Sprintf("\tUploading %s to target VM...", artifact))) //nolint:errcheck
89+
m.out.Write([]byte(fmt.Sprintf("\tUploading %s to target VM...", artifact))) //nolint:errcheck,staticcheck
9090
}
9191

9292
func (m *Messenger) UploadFileSucceeded() {
@@ -116,13 +116,13 @@ func (m *Messenger) DownloadFileFailed(errorMessage string) {
116116
func (m *Messenger) logValidateOSWarning(log string, errorMessage string) {
117117
matchingVersionWarning := "Ensure the version of the stemcell you're trying to build matches the corresponding base ISO you're using.\n" +
118118
"For example: If you're building 2019.x, then you should be using 'Windows Server 2019' only"
119-
m.out.Write([]byte(fmt.Sprintf("Warning: %s:\n%s\n%s", log, matchingVersionWarning, errorMessage))) //nolint:errcheck
119+
m.out.Write([]byte(fmt.Sprintf("Warning: %s:\n%s\n%s", log, matchingVersionWarning, errorMessage))) //nolint:errcheck,staticcheck
120120
}
121121

122122
func (m *Messenger) WaitingForShutdown() {
123123
t := time.Now()
124124
timeStampFormat := "2006-01-02T15:04:05.999999-07:00"
125-
m.out.Write([]byte(fmt.Sprintf("%s Still preparing VM...\n", t.Format(timeStampFormat)))) //nolint:errcheck
125+
m.out.Write([]byte(fmt.Sprintf("%s Still preparing VM...\n", t.Format(timeStampFormat)))) //nolint:errcheck,staticcheck
126126
}
127127

128128
func (m *Messenger) ShutdownCompleted() {

iaas_cli/govc_cli.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ func (r *GovcRunner) Run(args []string) int {
3131
}
3232

3333
func (r *GovcRunner) RunWithOutput(args []string) (string, int, error) {
34-
old := os.Stdout // keep backup of the real stdout
35-
reader, w, _ := os.Pipe()
34+
old := os.Stdout // keep backup of the real stdout
35+
reader, w, _ := os.Pipe() //nolint:errcheck
3636
os.Stdout = w
3737

3838
print()

0 commit comments

Comments
 (0)