Skip to content

Commit 9c9b93d

Browse files
committed
Format Go code with go fmt ./...; check formatting in CI
1 parent 91d2763 commit 9c9b93d

34 files changed

+218
-214
lines changed

.github/workflows/build.yaml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,46 @@ jobs:
1313
name: Build Windows
1414
runs-on: windows-latest
1515
steps:
16+
- name: Force git to use LF
17+
# This step is required on Windows to work around issues with go fmt.
18+
# TODO: replace with a checkout option when https://github.com/actions/checkout/issues/226 is implemented
19+
run: |
20+
git config --global core.autocrlf false
21+
git config --global core.eol lf
22+
23+
- name: Checkout code
24+
uses: actions/checkout@v6
25+
1626
- name: Set up Go 1.x
17-
uses: actions/setup-go@v3
27+
uses: actions/setup-go@v6
1828
with:
1929
go-version: 1.23
2030
id: go
2131

22-
- name: Checkout code
23-
uses: actions/checkout@v3
24-
25-
- name: Get dependencies
32+
- name: Format
2633
run: |
27-
go get -v -t -d ./...
34+
go fmt ./...
35+
git diff --exit-code
2836
- name: Test
2937
run: go test ./...
3038
build:
3139
name: Build Linux
3240
runs-on: ubuntu-latest
3341

3442
steps:
43+
- name: Checkout code
44+
uses: actions/checkout@v6
45+
3546
- name: Set up Go 1.x
36-
uses: actions/setup-go@v3
47+
uses: actions/setup-go@v6
3748
with:
3849
go-version: 1.23
3950
id: go
4051

41-
- name: Checkout code
42-
uses: actions/checkout@v3
43-
44-
- name: Get dependencies
52+
- name: Format
4553
run: |
46-
go get -v -t -d ./...
47-
if [ -f Gopkg.toml ]; then
48-
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
49-
dep ensure
50-
fi
54+
go fmt ./...
55+
git diff --exit-code
5156
- name: Test
5257
run: go test ./...
5358
- name: Coverage

bundler/bundler_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2319,8 +2319,8 @@ func TestCopySchemaToComponents_NameCollision(t *testing.T) {
23192319
func TestCalculateCollisionNameInline_NumericSuffix(t *testing.T) {
23202320
// Test: When filename-based name also collides, use numeric suffix
23212321
existingNames := map[string]bool{
2322-
"Cat": true,
2323-
"Cat__external": true, // Filename-based collision also exists
2322+
"Cat": true,
2323+
"Cat__external": true, // Filename-based collision also exists
23242324
"Cat__external__1": true, // First numeric suffix also taken (format: name__basename__N)
23252325
}
23262326

bundler/origin_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ func TestCaptureOrigin_FullCoverage(t *testing.T) {
914914
pr := &processRef{
915915
ref: &index.Reference{
916916
FullDefinition: "test.yaml",
917-
Node: &yaml.Node{Line: 5, Column: 2},
917+
Node: &yaml.Node{Line: 5, Column: 2},
918918
},
919919
idx: &index.SpecIndex{},
920920
originalName: "Test",

datamodel/high/base/dynamic_value.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ import (
2222
//
2323
// The N value indicates which value is set (0 = A, 1 == B), preventing the need to check both values.
2424
type DynamicValue[A any, B any] struct {
25-
N int // 0 == A, 1 == B
26-
A A
27-
B B
28-
inline bool
29-
renderCtx any // Context for inline rendering (typed as any to avoid import cycles)
25+
N int // 0 == A, 1 == B
26+
A A
27+
B B
28+
inline bool
29+
renderCtx any // Context for inline rendering (typed as any to avoid import cycles)
3030
}
3131

3232
// IsA will return true if the 'A' or left value is set.

datamodel/high/overlay/action.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import (
1313
// Action represents a high-level Overlay Action Object.
1414
// https://spec.openapis.org/overlay/v1.1.0#action-object
1515
type Action struct {
16-
Target string `json:"target,omitempty" yaml:"target,omitempty"`
17-
Description string `json:"description,omitempty" yaml:"description,omitempty"`
18-
Update *yaml.Node `json:"update,omitempty" yaml:"update,omitempty"`
19-
Remove bool `json:"remove,omitempty" yaml:"remove,omitempty"`
20-
Copy string `json:"copy,omitempty" yaml:"copy,omitempty"`
16+
Target string `json:"target,omitempty" yaml:"target,omitempty"`
17+
Description string `json:"description,omitempty" yaml:"description,omitempty"`
18+
Update *yaml.Node `json:"update,omitempty" yaml:"update,omitempty"`
19+
Remove bool `json:"remove,omitempty" yaml:"remove,omitempty"`
20+
Copy string `json:"copy,omitempty" yaml:"copy,omitempty"`
2121
Extensions *orderedmap.Map[string, *yaml.Node] `json:"-" yaml:"-"`
2222
low *low.Action
2323
}

datamodel/high/overlay/info.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import (
1313
// Info represents a high-level Overlay Info Object.
1414
// https://spec.openapis.org/overlay/v1.1.0#info-object
1515
type Info struct {
16-
Title string `json:"title,omitempty" yaml:"title,omitempty"`
17-
Version string `json:"version,omitempty" yaml:"version,omitempty"`
18-
Description string `json:"description,omitempty" yaml:"description,omitempty"`
16+
Title string `json:"title,omitempty" yaml:"title,omitempty"`
17+
Version string `json:"version,omitempty" yaml:"version,omitempty"`
18+
Description string `json:"description,omitempty" yaml:"description,omitempty"`
1919
Extensions *orderedmap.Map[string, *yaml.Node] `json:"-" yaml:"-"`
2020
low *low.Info
2121
}

datamodel/high/overlay/overlay.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import (
1313
// Overlay represents a high-level OpenAPI Overlay document.
1414
// https://spec.openapis.org/overlay/v1.0.0
1515
type Overlay struct {
16-
Overlay string `json:"overlay,omitempty" yaml:"overlay,omitempty"`
17-
Info *Info `json:"info,omitempty" yaml:"info,omitempty"`
18-
Extends string `json:"extends,omitempty" yaml:"extends,omitempty"`
19-
Actions []*Action `json:"actions,omitempty" yaml:"actions,omitempty"`
16+
Overlay string `json:"overlay,omitempty" yaml:"overlay,omitempty"`
17+
Info *Info `json:"info,omitempty" yaml:"info,omitempty"`
18+
Extends string `json:"extends,omitempty" yaml:"extends,omitempty"`
19+
Actions []*Action `json:"actions,omitempty" yaml:"actions,omitempty"`
2020
Extensions *orderedmap.Map[string, *yaml.Node] `json:"-" yaml:"-"`
2121
low *low.Overlay
2222
}

datamodel/high/v3/request_body_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,3 @@ paths: {}`
320320
assert.NoError(t, err)
321321
assert.NotNil(t, result)
322322
}
323-

datamodel/high/v3/security_scheme_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ func TestSecurityScheme_MarshalYAMLInlineWithContext_Reference(t *testing.T) {
157157
assert.Equal(t, "$ref", yamlNode.Content[0].Value)
158158
}
159159

160-
161160
func TestBuildLowSecurityScheme_Success(t *testing.T) {
162161
yml := `type: apiKey
163162
name: X-API-Key

datamodel/high/v3/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
// Server represents a high-level OpenAPI 3+ Server object, that is backed by a low level one.
1515
// - https://spec.openapis.org/oas/v3.1.0#server-object
1616
type Server struct {
17-
Name string `json:"name,omitempty" yaml:"name,omitempty"` // OpenAPI 3.2+ name field for documentation
17+
Name string `json:"name,omitempty" yaml:"name,omitempty"` // OpenAPI 3.2+ name field for documentation
1818
URL string `json:"url,omitempty" yaml:"url,omitempty"`
1919
Description string `json:"description,omitempty" yaml:"description,omitempty"`
2020
Variables *orderedmap.Map[string, *ServerVariable] `json:"variables,omitempty" yaml:"variables,omitempty"`

0 commit comments

Comments
 (0)