From f96cb3ad60c717ef5469d54cdbfaa85364e2b26f Mon Sep 17 00:00:00 2001 From: Avinal Kumar Date: Thu, 15 Jun 2023 07:27:09 +0000 Subject: [PATCH] chore: add go format check and update go version - go 1.18 has reached end of life, use go 1.20 - fix formatting errors Signed-off-by: Avinal Kumar --- .github/workflows/go.yml | 16 ++++++++++++++-- pkg/authenticate/doc.go | 2 +- pkg/models/doc.go | 2 +- pkg/models/types.go | 1 - 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 7480b25..ddce0bb 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -8,6 +8,7 @@ on: branches: [ "main" ] pull_request: branches: [ "main" ] + workflow_dispatch: jobs: @@ -17,9 +18,20 @@ jobs: - uses: actions/checkout@v3 - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: - go-version: 1.18 + go-version: '1.20' + check-latest: true + cache: true + + - name: Check Formatting + run: | + find . -name '*.go' -not -path './vendor/*' | xargs gofmt -d -s > gofmt.out + if [[ -s gofmt.out ]]; then + echo "The following files were found to have formatting deviations:" + cat gofmt.out + exit 1 + fi - name: Build run: go build -v ./... diff --git a/pkg/authenticate/doc.go b/pkg/authenticate/doc.go index fa4c654..bae6d1b 100644 --- a/pkg/authenticate/doc.go +++ b/pkg/authenticate/doc.go @@ -1,5 +1,5 @@ // SPDX-FileCopyrightText: 2023 Kavya Shukla // SPDX-License-Identifier: GPL-2.0-only -//Package authenticate is build to authenticate the API. +// Package authenticate is build to authenticate the API. package authenticate diff --git a/pkg/models/doc.go b/pkg/models/doc.go index 3f37110..748d09a 100644 --- a/pkg/models/doc.go +++ b/pkg/models/doc.go @@ -2,5 +2,5 @@ // SPDX-License-Identifier: GPL-2.0-only // Package models is made to connect the database and to store the structs of -//different data. +// different data. package models diff --git a/pkg/models/types.go b/pkg/models/types.go index ea5822f..7911652 100644 --- a/pkg/models/types.go +++ b/pkg/models/types.go @@ -3,7 +3,6 @@ package models -// type License struct { Shortname string `json:"rf_shortname" gorm:"primary_key"` Fullname string `json:"rf_fullname"`