Skip to content

Commit c3bdf23

Browse files
authoredJun 29, 2020
Add gofmt -s to CI (hashicorp#146)
* Add gofmt to CI * Apply gofmt -s * Add check job to CI * Install go-fmt-fail * Revert "Add check job to CI" This reverts commit f923bc2. * Fix Makefile fmt command * Add .gitattributes
1 parent e40f7c5 commit c3bdf23

File tree

21 files changed

+469
-5
lines changed

21 files changed

+469
-5
lines changed
 

‎.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.go text eol=lf

‎.github/workflows/ci.yml

+3
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ jobs:
5353
-
5454
name: Go mod verify
5555
run: go mod verify
56+
-
57+
name: Run go fmt
58+
run: make fmt
5659
-
5760
name: Run tests
5861
run: make test

‎Makefile

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
export GOFLAGS = -mod=vendor
2+
13
default: test
24

5+
fmt:
6+
go run github.com/mh-cbon/go-fmt-fail ./...
7+
38
test:
4-
go test -mod=vendor -v -cover ./...
9+
go test -v -cover ./...
510

6-
.PHONY: test
11+
.PHONY: fmt test

‎go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ require (
1111
github.com/hashicorp/go-version v1.2.0
1212
github.com/hashicorp/hcl/v2 v2.5.2-0.20200528183353-fa7c453538de
1313
github.com/hashicorp/terraform-json v0.5.0
14+
github.com/mh-cbon/go-fmt-fail v0.0.0-20160815164508-67765b3fbcb5
1415
github.com/mitchellh/cli v1.0.0
1516
github.com/pmezard/go-difflib v1.0.0
1617
github.com/sourcegraph/go-lsp v0.0.0-20200117082640-b19bb38222e2

‎go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRU
5151
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
5252
github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI=
5353
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
54+
github.com/mh-cbon/go-fmt-fail v0.0.0-20160815164508-67765b3fbcb5 h1:shw+DWUaHIyW64Tv30ASCbC6QO6fLy+M5SJb5pJVEI4=
55+
github.com/mh-cbon/go-fmt-fail v0.0.0-20160815164508-67765b3fbcb5/go.mod h1:nHPoxaBUc5CDAMIv0MNmn5PBjWbTs9BI/eh30/n0U6g=
5456
github.com/mitchellh/cli v1.0.0 h1:iGBIsUe3+HZ/AD/Vd7DErOt5sU9fa8Uj7A2s1aggv1Y=
5557
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
5658
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM=

‎internal/terraform/lang/config_block_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ func TestCompletableLabels_CompletionCandidatesAtPos_overLimit(t *testing.T) {
301301
},
302302
tBlock: tBlock,
303303
labels: map[string][]*labelCandidate{
304-
"type": []*labelCandidate{
304+
"type": {
305305
{label: "aaa"},
306306
{label: "bbb"},
307307
{label: "ccc"},
@@ -338,7 +338,7 @@ func TestCompletableLabels_CompletionCandidatesAtPos_matchingLimit(t *testing.T)
338338
},
339339
tBlock: tBlock,
340340
labels: map[string][]*labelCandidate{
341-
"type": []*labelCandidate{
341+
"type": {
342342
{label: "aaa"},
343343
{label: "bbb"},
344344
},
@@ -374,7 +374,7 @@ func TestCompletableLabels_CompletionCandidatesAtPos_withPrefix(t *testing.T) {
374374
},
375375
tBlock: tBlock,
376376
labels: map[string][]*labelCandidate{
377-
"type": []*labelCandidate{
377+
"type": {
378378
{label: "prov_aaa"},
379379
{label: "prov_bbb"},
380380
{label: "ccc"},

‎tools.go

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// +build tools
2+
3+
package main
4+
5+
import _ "github.com/mh-cbon/go-fmt-fail"

‎vendor/github.com/mh-cbon/go-fmt-fail/.gitignore

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎vendor/github.com/mh-cbon/go-fmt-fail/.travis.yml

+51
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎vendor/github.com/mh-cbon/go-fmt-fail/.version

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎vendor/github.com/mh-cbon/go-fmt-fail/CHANGELOG.md

+75
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎vendor/github.com/mh-cbon/go-fmt-fail/LICENSE

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎vendor/github.com/mh-cbon/go-fmt-fail/README.md

+53
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎vendor/github.com/mh-cbon/go-fmt-fail/appveyor.yml

+56
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.