Skip to content

Commit 0f9a916

Browse files
authored
fix(go_format): add go format check in githu actions (#4)
Signed-off-by: Ashutosh Kumar <sonasingh46@gmail.com>
1 parent bdae320 commit 0f9a916

19 files changed

Lines changed: 51 additions & 1868 deletions

File tree

.github/workflows/main.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,26 @@ on:
1313
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1414
jobs:
1515
# This workflow contains a single job called "build"
16-
build:
16+
test:
1717
# The type of runner that the job will run on
1818
runs-on: ubuntu-latest
1919

2020
# Steps represent a sequence of tasks that will be executed as part of the job
2121
steps:
22-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
23-
- uses: actions/checkout@v2
2422

25-
# Runs a single command using the runners shell
26-
- name: Run a one-line script
27-
run: echo Hello, world!
23+
- name: Set up Go 1.13
24+
uses: actions/setup-go@v1
25+
with:
26+
go-version: 1.13
27+
id: go
2828

29-
# Runs a set of commands using the runners shell
30-
- name: Run a multi-line script
29+
- name: Check out code into the Go module directory
30+
uses: actions/checkout@v1
31+
with:
32+
fetch-depth: 1
33+
path: go/src/github.com/sonasingh46/github-actions
34+
35+
# Check for go formatting
36+
- name: Enforce Go Formatting
3137
run: |
32-
echo Add other actions to build,
33-
echo test, and deploy your project.
38+
! go fmt ./... 2>&1 | read

cmd/bar/main.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1+
/*
2+
Copyright (c) 2020-present Author(sonasingh46@gmail.com). All Rights Reserved.
3+
See LICENSE.txt for license information.
4+
*/
5+
16
package main
27

38
import (
9+
"fmt"
410
"github.com/sonasingh46/github-actions/pkg/foo"
5-
"k8s.io/klog"
611
)
7-
func main() {
8-
klog.InitFlags(nil)
9-
number:=3
10-
if foo.IsEven(number){
11-
klog.Infof("%d is even",number)
12-
}else {
13-
klog.Infof("%d is odd",number)
12+
13+
func main() {
14+
15+
number := 3
16+
if foo.IsEven(number) {
17+
fmt.Println("%d is even", number)
18+
} else {
19+
fmt.Println("%d is odd", number)
1420

1521
}
16-
}
22+
}

go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
module github.com/sonasingh46/github-actions
22

33
go 1.13
4-
5-
require k8s.io/klog v1.0.0

go.sum

Lines changed: 0 additions & 3 deletions
This file was deleted.

pkg/foo/foo.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
/*
2+
Copyright (c) 2020-present Author(sonasingh46@gmail.com). All Rights Reserved.
3+
See LICENSE.txt for license information.
4+
*/
5+
16
package foo
27

38
// IsEven returns true if the provided number is even else returns false.
4-
func IsEven(number int)bool {
5-
return (number%2)==0
6-
}
9+
func IsEven(number int) bool {
10+
return (number % 2) == 0
11+
}

pkg/foo/foo_test.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
Copyright (c) 2020-present Author(sonasingh46@gmail.com). All Rights Reserved.
3+
See LICENSE.txt for license information.
4+
*/
5+
16
package foo
27

38
import "testing"
@@ -12,19 +17,19 @@ func TestIsEven(t *testing.T) {
1217
want bool
1318
}{
1419
{
15-
name:"Test Case #1",
16-
args:args{
17-
number:2,
20+
name: "Test Case #1",
21+
args: args{
22+
number: 2,
1823
},
19-
want:true,
24+
want: true,
2025
},
2126

2227
{
23-
name:"Test Case #2",
24-
args:args{
25-
number:3,
28+
name: "Test Case #2",
29+
args: args{
30+
number: 3,
2631
},
27-
want:false,
32+
want: false,
2833
},
2934
}
3035
for _, tt := range tests {

vendor/k8s.io/klog/.travis.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

vendor/k8s.io/klog/CONTRIBUTING.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

vendor/k8s.io/klog/LICENSE

Lines changed: 0 additions & 191 deletions
This file was deleted.

vendor/k8s.io/klog/OWNERS

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)