Skip to content

Commit 0d5814a

Browse files
authored
chore: use golangci-lint and gofumpt (#408)
1 parent 67b851e commit 0d5814a

39 files changed

+520
-487
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ jobs:
99
name: Lint
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v3
12+
- uses: actions/checkout@v4
1313
- name: Set up Go 1.x
14-
uses: actions/setup-go@v4
14+
uses: actions/setup-go@v5
1515
with:
1616
go-version: ^1.19.9
17+
cache: false
1718
id: go
1819
- name: golangci-lint
1920
uses: golangci/golangci-lint-action@v3
@@ -28,16 +29,16 @@ jobs:
2829
runs-on: ${{ matrix.os }}
2930
name: ${{ matrix.browser }} on ${{ matrix.os }}
3031
steps:
31-
- uses: actions/checkout@v3
32+
- uses: actions/checkout@v4
3233
with:
3334
submodules: true
3435
- name: Set up Go
35-
uses: actions/setup-go@v4
36+
uses: actions/setup-go@v5
3637
with:
3738
go-version: ^1.19.9
3839
id: go
3940
- name: Cache drivers
40-
uses: actions/cache@v3
41+
uses: actions/cache@v4
4142
with:
4243
# In order:
4344
# * Driver for linux
@@ -78,9 +79,9 @@ jobs:
7879
needs: test
7980
runs-on: ubuntu-latest
8081
steps:
81-
- uses: actions/checkout@v3
82+
- uses: actions/checkout@v4
8283
- name: Set up Go
83-
uses: actions/setup-go@v4
84+
uses: actions/setup-go@v5
8485
with:
8586
go-version: ^1.19.9
8687
id: go
@@ -95,9 +96,9 @@ jobs:
9596
test-examples:
9697
runs-on: ubuntu-latest
9798
steps:
98-
- uses: actions/checkout@v3
99+
- uses: actions/checkout@v4
99100
- name: Set up Go 1.x
100-
uses: actions/setup-go@v4
101+
uses: actions/setup-go@v5
101102
with:
102103
go-version: ^1.19.9
103104
id: go

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
name: Deploy docs
88
runs-on: ubuntu-20.04
99
steps:
10-
- uses: actions/checkout@v3
10+
- uses: actions/checkout@v4
1111
- uses: ruby/setup-ruby@v1
1212
with:
1313
ruby-version: 2.7

.github/workflows/verify_type_generation.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ jobs:
88
verify:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v3
11+
- uses: actions/checkout@v4
1212
with:
1313
submodules: true
1414
- name: Set up Go
15-
uses: actions/setup-go@v4
15+
uses: actions/setup-go@v5
1616
with:
1717
go-version: ^1.19.9
18+
- name: Install gofumpt
19+
run: go install mvdan.cc/gofumpt@latest
1820
- name: Install Browsers
1921
run: |
2022
go install ./...

.golangci.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
linters:
3+
enable-all: false
4+
disable-all: false
5+
enable:
6+
- gofumpt

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Contributing
22

3+
## Code style
4+
The Go code is linted with [golangci-lint](https://golangci-lint.run/) and formatted with [gofumpt](https://github.com/mvdan/gofumpt). Please configure your editor to run the tools while developing and make sure to run the tools before committing any code.
5+
36
## Tests
47

58
### Test coverage

browser.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,11 @@ func (b *browserImpl) StopTracing() ([]byte, error) {
179179
return binary, err
180180
}
181181
if b.chromiumTracingPath != nil {
182-
err := os.MkdirAll(filepath.Dir(*b.chromiumTracingPath), 0777)
182+
err := os.MkdirAll(filepath.Dir(*b.chromiumTracingPath), 0o777)
183183
if err != nil {
184184
return binary, err
185185
}
186-
err = os.WriteFile(*b.chromiumTracingPath, binary, 0644)
186+
err = os.WriteFile(*b.chromiumTracingPath, binary, 0o644)
187187
if err != nil {
188188
return binary, err
189189
}

browser_context.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func (b *browserContextImpl) Pages() []Page {
6666
func (b *browserContextImpl) Browser() Browser {
6767
return b.browser
6868
}
69+
6970
func (b *browserContextImpl) Tracing() Tracing {
7071
return b.tracing
7172
}

browser_type.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ func (b *browserTypeImpl) LaunchPersistentContext(userDataDir string, options ..
8787
b.didCreateContext(context, option, tracesDir)
8888
return context, nil
8989
}
90+
9091
func (b *browserTypeImpl) Connect(wsEndpoint string, options ...BrowserTypeConnectOptions) (Browser, error) {
9192
overrides := map[string]interface{}{
9293
"wsEndpoint": wsEndpoint,

element_handle.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func (e *elementHandleImpl) Screenshot(options ...ElementHandleScreenshotOptions
268268
return nil, fmt.Errorf("could not decode base64 :%w", err)
269269
}
270270
if path != nil {
271-
if err := os.WriteFile(*path, image, 0644); err != nil {
271+
if err := os.WriteFile(*path, image, 0o644); err != nil {
272272
return nil, err
273273
}
274274
}

examples/javascript/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,4 @@ func main() {
4545
if err := pw.Stop(); err != nil {
4646
log.Fatalf("could not stop Playwright: %v\n", err)
4747
}
48-
4948
}

0 commit comments

Comments
 (0)